Submission #953600


Source Code Expand

#include <bits/stdc++.h>
#define endl '\n'

using namespace std;


int tests,current_case;
int n;
char a[128],b[128];
int ans;

void message(int current_case) {
    //cerr<<"Case "<<current_case<<" solved!"<<endl;
    fprintf(stderr, "Case %d solved!\n", current_case);
}

bool check(int l) {
    int i,j;
    for(i=n-l+1,j=1;i<=n;i++,j++) if(a[i]!=b[j]) return false;
    return true;
}

int main() {
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    int i;

    tests=1;
    //scanf("%d", &tests);
    //cin>>tests;
    for(current_case=1;current_case<=tests;current_case++) {
        scanf("%d", &n);
        scanf("%s", a+1);
        scanf("%s", b+1);
        ans=n+n;
        for(i=1;i<=n;i++) if(check(i)) ans=min(ans,n+n-i);
        printf("%d\n", ans);
        message(current_case);
    }

    return 0;
}

Submission Info

Submission Time
Task A - Prefix and Suffix
User Extazy
Language C++14 (GCC 5.4.1)
Score 200
Code Size 872 Byte
Status AC
Exec Time 3 ms
Memory 256 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:32:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &n);
                        ^
./Main.cpp:33:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%s", a+1);
                         ^
./Main.cpp:34:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%s", b+1);
                         ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 3
AC × 9
Set Name Test Cases
Sample 0_00.txt, 0_01.txt, 0_02.txt
All 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt
Case Name Status Exec Time Memory
0_00.txt AC 3 ms 256 KB
0_01.txt AC 3 ms 256 KB
0_02.txt AC 3 ms 256 KB
1_00.txt AC 3 ms 256 KB
1_01.txt AC 3 ms 256 KB
1_02.txt AC 3 ms 256 KB
1_03.txt AC 3 ms 256 KB
1_04.txt AC 3 ms 256 KB
1_05.txt AC 3 ms 256 KB