Submission #953850
Source Code Expand
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#ifdef WIN32
#define LL "%I64d"
#else
#define LL "%lld"
#endif
#ifdef CT
#define debug(...) printf(__VA_ARGS__)
#define setfile()
#else
#define debug(...)
#define filename ""
#define setfile() freopen(filename".in", "r", stdin); freopen(filename".out", "w", stdout)
#endif
#define R register
#define getc() (S == T && (T = (S = B) + fread(B, 1, 1 << 15, stdin), S == T) ? EOF : *S++)
#define dmax(_a, _b) ((_a) > (_b) ? (_a) : (_b))
#define dmin(_a, _b) ((_a) < (_b) ? (_a) : (_b))
#define cmax(_a, _b) (_a < (_b) ? _a = (_b) : 0)
#define cmin(_a, _b) (_a > (_b) ? _a = (_b) : 0)
#define cabs(_x) ((_x) < 0 ? (- (_x)) : (_x))
char B[1 << 15], *S = B, *T = B;
inline int F()
{
R char ch; R int cnt = 0; R bool minus = 0;
while (ch = getc(), (ch < '0' || ch > '9') && ch != '-') ;
ch == '-' ? minus = 1 : cnt = ch - '0';
while (ch = getc(), ch >= '0' && ch <= '9') cnt = cnt * 10 + ch - '0';
return minus ? -cnt : cnt;
}
#define maxn 110
int n;
char a[maxn], b[maxn];
int main()
{
// setfile();
scanf("%d", &n);
scanf("%s%s", a + 1, b + 1);
for (R int i = 1; i <= n; ++i)
{
R bool check = 1;
for (R int j = i, k = 1; j <= n && check; ++j, ++k)
if (a[j] != b[k]) check = 0;
if (check) return !printf("%d\n", i + n - 1 );
}
printf("%d\n", n * 2 );
return 0;
}
Submission Info
Submission Time
2016-10-29 21:08:15+0900
Task
A - Prefix and Suffix
User
chentong
Language
C++14 (GCC 5.4.1)
Score
200
Code Size
1417 Byte
Status
AC
Exec Time
9 ms
Memory
128 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:43:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n);
^
./Main.cpp:44:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%s%s", a + 1, b + 1);
^
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
9 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