Submission #532982


Source Code Expand

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
using namespace std;

const int N = 110;

char s[N], f[]="tokyo", g[]="kyoto";

bool ok(int x){
    bool flag = 0;
    for(int i=0; i<5; i++){
        if(s[x+i] != f[i]){
            flag = 1;
            break;
        }
    }
    if(!flag)   return 1;
    flag = 0;
    for(int i=0; i<5; i++){
        if(s[x+i] != g[i]){
            flag = 1;
            break;
        }
    }
    if(flag)    return 0;
    return 1;
}

int T, n;
int main(){
    scanf("%d", &T);
    while(T--){
        scanf("%s", s);
        n = strlen(s);
        int ans = 0;
        for(int i=0; i+5<=n; i++){
            if(ok(i)){
                ans++;
                i+=4;
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}

Submission Info

Submission Time
Task A - 東京都
User hongrock
Language C++ (GCC 4.9.2)
Score 100
Code Size 849 Byte
Status AC
Exec Time 25 ms
Memory 800 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:33:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &T);
                    ^
./Main.cpp:35:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%s", s);
                       ^

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 3
Set Name Test Cases
All 10_random_to_kyo.txt, 20_noised_tokyoto.txt, 99_teuchi.txt
Case Name Status Exec Time Memory
10_random_to_kyo.txt AC 25 ms 800 KB
20_noised_tokyoto.txt AC 22 ms 700 KB
99_teuchi.txt AC 22 ms 712 KB