Submission #1227241
Source Code Expand
#include<cstdio> #include<iostream> #include<algorithm> #include<cstdlib> #include<cstring> #include<string> #include<climits> #include<vector> #include<cmath> #include<map> #define LL long long #define pii pair<int,int> #define mp make_pair using namespace std; inline char nc(){ /* static char buf[100000],*p1=buf,*p2=buf; if (p1==p2) { p2=(p1=buf)+fread(buf,1,100000,stdin); if (p1==p2) return EOF; } return *p1++; */return getchar(); } inline void read(int &x){ char c=nc();int b=1; for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1; for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b; } inline void read(LL &x){ char c=nc();LL b=1; for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1; for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b; } inline int read(char *s) { char c=nc();int len=1; for(;!(c>='a' && c<='z');c=nc()) if (c==EOF) return 0; for(;(c>='a' && c<='z');s[len++]=c,c=nc()); s[len++]='\0'; return len; } inline void read(char &x){ for (x=nc();!(x>='A' && x<='Z');x=nc()); } int wt,ss[19]; inline void print(int x){ if (x<0) x=-x,putchar('-'); if (!x) putchar(48); else { for (wt=0;x;ss[++wt]=x%10,x/=10); for (;wt;putchar(ss[wt]+48),wt--);} } inline void print(LL x){ if (x<0) x=-x,putchar('-'); if (!x) putchar(48); else {for (wt=0;x;ss[++wt]=x%10,x/=10);for (;wt;putchar(ss[wt]+48),wt--);} } int n,m; char s[110],t[110],p[210]; bool check(int x) { for (int i=1;i<=n;i++) if (s[i]!=p[i]) return false; return true; } int main() { n=read(s),n=strlen(s+1); m=read(t);int x=0; for (int i=n;i<=n+n;i++) { for (int j=1;j<=i-n;j++) p[j]=s[j]; for (int j=1;j<=n;j++) p[(i-n)+j]=t[j]; if (check(i)) {print(i),puts("");return 0;} } return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Prefix and Suffix |
User | vjudge1 |
Language | C++14 (GCC 5.4.1) |
Score | 200 |
Code Size | 1737 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 |