Submission #3434166
Source Code Expand
#include<iostream> #include<vector> #include<algorithm> #include<cctype> #include<utility> #include<string> #include<cmath> #include <numeric> #include<climits> #define REP(i, n) for(int i = 0;i < n;i++) #define REPR(i, n) for(int i = n;i >= 0;i--) #define FOR(i, m, n) for(int i = m;i < n;i++) #define FORR(i, m, n) for(int i = m;i >= n;i--) #define SORT(v, n) sort(v, v+n); #define VSORT(v) sort(v.begin(), v.end()); #define llong long long #define pb(a) push_back(a) #define INF LLONG_MAX using namespace std; typedef pair<int, int> P; typedef pair<llong, llong> LP; typedef pair<int, P> PP; typedef pair<llong, LP> LPP; typedef long long int ll; #define ARRAY_MAX 100005 int main(){ int n; cin >> n; string s,t,ans; cin >> s >> t; bool flag = false; for(int i = 0;i < s.length();i++){ //cout << i << endl; string s2 = s.substr(i,s.length()-i); string t2 = t.substr(0,s.length()-i); if(s2 == t2){ flag = true; for(int j = 0;j < n;j++){ ans.push_back(t[j]); } break; }else{ ans.push_back(s[i]); } } if(!flag){ for(int i = 0;i < t.length();i++){ ans.push_back(t[i]); } } cout << ans.length() << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Prefix and Suffix |
User | punipuni |
Language | C++14 (GCC 5.4.1) |
Score | 200 |
Code Size | 1380 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 |