Submission #954470


Source Code Expand

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <math.h>

#define MOD 1000000007
#define REP(i,n) for ((i)=0;i<(n);i++)
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define LL long long
#define ULL unsigned long long

int compare_ll(const void *a, const void *b){
	return *(ULL*)b - *(ULL*)a;
}

int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}

int main(void) {

	int N,i,j,k,temp;
	char s[101],t[101];

	scanf("%d", &N);
	scanf("%s", &s);
	scanf("%s", &t);

	if(strlen(s)+strlen(t)<=N){
		printf("%d", N);
	}else{
		for(i=0;i<strlen(s);i++){
			temp = 0;
			for(j=0;j<strlen(s)-i;j++){
				if(s[i+j]==t[j]){
					temp++;
				}else{
					temp = 0;
					break;
				}
			}
			if(temp != 0){
				break;
			}
		}
		if(strlen(s)+strlen(t)-temp<=N){
			printf("%d", N);
		}else{
			printf("%d", strlen(s)+strlen(t)-temp);
		}
	}

	return 0;
}

/* 最後の改行忘れるな!! */

Submission Info

Submission Time
Task A - Prefix and Suffix
User Ryui
Language C (GCC 5.4.1)
Score 200
Code Size 1096 Byte
Status AC
Exec Time 1 ms
Memory 128 KB

Compile Error

./Main.c: In function ‘main’:
./Main.c:32:8: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char (*)[101]’ [-Wformat=]
  scanf("%s", &s);
        ^
./Main.c:33:8: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char (*)[101]’ [-Wformat=]
  scanf("%s", &t);
        ^
./Main.c:55:11: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘size_t {aka long unsigned int}’ [-Wformat=]
    printf("%d", strlen(s)+strlen(t)-temp);
           ^
./Main.c:31:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
  ^
./Main.c:32:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s", &s);
  ^
./Main.c:33:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s", &t);
  ^

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 128 KB
0_01.txt AC 1 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