Submission #3123595


Source Code Expand

n;char s[222];l,r;
main(){
	scanf("%d%s",&n,s);
	r=strlen(s)-1;
	for(;l<r;)
	{
		if(s[l]=='c'&&s[r]=='a')l++,r--;
		else if(s[l]=='a'&&s[r]=='c')l++,r--;
		else if(s[l]=='b'&&s[r]=='b')l++,r--;
		else break;
	}
	printf("%d\n",l==r&&s[r]=='b'?n/2:-1);
}

Submission Info

Submission Time
Task B - 手芸王
User kotatsugame
Language C (GCC 5.4.1)
Score 100
Code Size 264 Byte
Status AC
Exec Time 1 ms
Memory 128 KB

Compile Error

./Main.c:1:1: warning: data definition has no type or storage class
 n;char s[222];l,r;
 ^
./Main.c:1:1: warning: type defaults to ‘int’ in declaration of ‘n’ [-Wimplicit-int]
./Main.c:1:15: warning: data definition has no type or storage class
 n;char s[222];l,r;
               ^
./Main.c:1:15: warning: type defaults to ‘int’ in declaration of ‘l’ [-Wimplicit-int]
./Main.c:1:17: warning: type defaults to ‘int’ in declaration of ‘r’ [-Wimplicit-int]
 n;char s[222];l,r;
                 ^
./Main.c:2:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
 main(){
 ^
./Main.c: In function ‘main’:
./Main.c:3:2: warning: implicit declaration of function ‘scanf’ [-Wimplicit-function-declaration]
  scanf("%d%s",&n,s);
  ^
./Main.c:3:2: warning: incompatible implicit declaration of built-in function ‘scanf’
./Main.c:3:2: note: include ‘<stdio.h>’ or provide a declaration of ‘scanf’
./Main.c:4:4: warning: implicit declaration of function ‘strlen’ [-Wimplicit-function-declaration]
  r=strlen(s)-1;
    ^
./Mai...

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 4
AC × 29
Set Name Test Cases
Sample subtask0-sample01.txt, subtask0-sample02.txt, subtask0-sample03.txt, subtask0-sample04.txt
All subtask0-sample01.txt, subtask0-sample02.txt, subtask0-sample03.txt, subtask0-sample04.txt, subtask1-01.txt, subtask1-02.txt, subtask1-03.txt, subtask1-04.txt, subtask1-05.txt, subtask1-06.txt, subtask1-07.txt, subtask1-08.txt, subtask1-09.txt, subtask1-10.txt, subtask1-11.txt, subtask1-12.txt, subtask1-13.txt, subtask1-14.txt, subtask1-15.txt, subtask1-16.txt, subtask1-17.txt, subtask1-18.txt, subtask1-19.txt, subtask1-20.txt, subtask1-21.txt, subtask1-22.txt, subtask1-23.txt, subtask1-24.txt, subtask1-25.txt
Case Name Status Exec Time Memory
subtask0-sample01.txt AC 1 ms 128 KB
subtask0-sample02.txt AC 1 ms 128 KB
subtask0-sample03.txt AC 1 ms 128 KB
subtask0-sample04.txt AC 1 ms 128 KB
subtask1-01.txt AC 1 ms 128 KB
subtask1-02.txt AC 1 ms 128 KB
subtask1-03.txt AC 1 ms 128 KB
subtask1-04.txt AC 1 ms 128 KB
subtask1-05.txt AC 1 ms 128 KB
subtask1-06.txt AC 1 ms 128 KB
subtask1-07.txt AC 1 ms 128 KB
subtask1-08.txt AC 1 ms 128 KB
subtask1-09.txt AC 1 ms 128 KB
subtask1-10.txt AC 1 ms 128 KB
subtask1-11.txt AC 1 ms 128 KB
subtask1-12.txt AC 1 ms 128 KB
subtask1-13.txt AC 1 ms 128 KB
subtask1-14.txt AC 1 ms 128 KB
subtask1-15.txt AC 1 ms 128 KB
subtask1-16.txt AC 1 ms 128 KB
subtask1-17.txt AC 1 ms 128 KB
subtask1-18.txt AC 1 ms 128 KB
subtask1-19.txt AC 1 ms 128 KB
subtask1-20.txt AC 1 ms 128 KB
subtask1-21.txt AC 1 ms 128 KB
subtask1-22.txt AC 0 ms 128 KB
subtask1-23.txt AC 0 ms 128 KB
subtask1-24.txt AC 1 ms 128 KB
subtask1-25.txt AC 1 ms 128 KB