Submission #1185231
Source Code Expand
#include <bits/stdc++.h>
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
struct S002 {
int n;
S002& operator > (long& x) {
n = x;
return *this;
}
S002& operator > (long&& x) {
n = x;
return *this;
}
S002& operator >= (long& x) {
if( scanf("%ld", &x) <= 0 ) exit(0);
return *this;
}
S002& operator >= (double& x) {
if( scanf("%lf", &x) <= 0 ) exit(0);
return *this;
}
S002& operator >= (std::string& s) {
if( not (std::cin >> s) ) exit(0);
return *this;
}
template<typename a>
S002& operator >= (std::vector<a>& v) {
v.resize(n);
for(long i = 0; i < n; ++i) {
*this >= v[i];
}
return *this;
}
template<typename a, std::size_t s>
S002& operator >= (std::array<a, s>& x) {
for(long i = 0; i < (long)s; ++i) {
*this >= x[i];
}
return *this;
}
};
struct Solver {
long n;
std::string x, y;
Solver() {
S002 reader;
reader >= n >= x >= y;
}
void solve() {
for(long i = 0; i < n; ++i) {
bool flag = true;
for(long j = 0; j < n - i; ++j) {
if( x[i+j] != y[j] ) {
flag = false;
}
}
if( flag ) {
printf("%ld\n", n + i);
return;
}
}
printf("%ld\n", n + n);
}
};
int main() {
loop std::unique_ptr<Solver>(new Solver())->solve();
return 0;
}
Submission Info
Submission Time |
|
Task |
A - Prefix and Suffix |
User |
spica314 |
Language |
C++14 (GCC 5.4.1) |
Score |
200 |
Code Size |
1875 Byte |
Status |
AC |
Exec Time |
1 ms |
Memory |
256 KB |
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 |
256 KB |
0_01.txt |
AC |
1 ms |
256 KB |
0_02.txt |
AC |
1 ms |
256 KB |
1_00.txt |
AC |
1 ms |
256 KB |
1_01.txt |
AC |
1 ms |
256 KB |
1_02.txt |
AC |
1 ms |
256 KB |
1_03.txt |
AC |
1 ms |
256 KB |
1_04.txt |
AC |
1 ms |
256 KB |
1_05.txt |
AC |
1 ms |
256 KB |