Submission #1227246


Source Code Expand

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#include<vector>
#include<map>

#define For(i,a,b) for(int i=a;i<=b;i++)
#define ForD(i,a,b) for (int i=a;i>=b;i--)
#define LL long long
#define INF (2147483647)
#define sqr(x)	((x)*(x))

using namespace std;

inline int read(){
    int data=0,w=1; char ch=0;
    while (ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if (ch=='-') w=-1,ch=getchar();
    while  (ch>='0' && ch<='9') data=data*10+ch-'0',ch=getchar();
    return data*w;
}

inline void write(int x){
	if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
} 

char s1[200],s2[200];
int t;

int main(){	
	int n=read();
	scanf("%s",s1+1);
	scanf("%s",s2+1);
	
	For(i,1,n+1){
		bool t=true;
		For(j,i,n)
			if (s1[j]!=s2[j-i+1]){
				t=false;break;
			}
		if (t){
			write((i-1)*2+(n-i+1)),puts("");
		/*	printf("The shortest string is ");
			For(j,1,n)
				putchar(s1[j]);
			For(j,n-i+2,n)
				putchar(s2[j]);
			puts("");*/
			break;
		}
	}	
	
} 

Submission Info

Submission Time
Task A - Prefix and Suffix
User vjudge1
Language C++14 (GCC 5.4.1)
Score 200
Code Size 1034 Byte
Status AC
Exec Time 1 ms
Memory 256 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:37:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s",s1+1);
                  ^
./Main.cpp:38:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s",s2+1);
                  ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 3
AC × 9
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