Submission #958147
Source Code Expand
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)
int N;
char s[111];
char t[111];
int a;
int main(){
scanf("%d" , &N);
scanf(" %s %s" , s , t);
repm(i,N,0){
repp(j,0,i){
if(s[N - i + j] != t[j]) break;
if(j + 1 == i){
printf("%d\n", N + N - i);
return 0;
}
}
}
printf("%d\n" , N * 2);
return 0;
}
Submission Info
Submission Time |
|
Task |
A - Prefix and Suffix |
User |
PIandS |
Language |
C++14 (GCC 5.4.1) |
Score |
200 |
Code Size |
1041 Byte |
Status |
AC |
Exec Time |
1 ms |
Memory |
128 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:30:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d" , &N);
^
./Main.cpp:31:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf(" %s %s" , s , t);
^
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
200 / 200 |
Status |
|
|
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 |
1 ms |
128 KB |
0_01.txt |
AC |
1 ms |
128 KB |
0_02.txt |
AC |
1 ms |
128 KB |
1_00.txt |
AC |
1 ms |
128 KB |
1_01.txt |
AC |
1 ms |
128 KB |
1_02.txt |
AC |
1 ms |
128 KB |
1_03.txt |
AC |
1 ms |
128 KB |
1_04.txt |
AC |
1 ms |
128 KB |
1_05.txt |
AC |
1 ms |
128 KB |