提出 #533427


ソースコード 拡げる

#include<iostream>
#include<string>
using namespace std;

int ans = 0;
string tokyo = "tokyo";
string kyoto = "kyoto";


int main(){
    int t;
    cin >> t;
    for (int i = 0; i < t; i++) {
        string s;
        cin >> s;
        ans = 0;
        int j = 0;
        while (j < s.size()) {
            if (s[j] == 't') {
                if (j+4<= s.size()-1 && s.substr(j,5) == tokyo) {
                    ans++;
                    j = j+5;
                }else{
                    j++;
                }
            }else if (s[j] == 'k') {
                if (j+4<= s.size()-1 && s.substr(j,5) == kyoto) {
                    ans++;
                    j = j+5;
                }else{
                    j++;
                }
            }else{
                j++;
            }
        }
        cout << ans<< endl;
    }
    return 0;
}

提出情報

提出日時
問題 A - 東京都
ユーザ taijin
言語 C++ (GCC 4.9.2)
得点 100
コード長 891 Byte
結果 AC
実行時間 32 ms
メモリ 1136 KiB

ジャッジ結果

セット名 All
得点 / 配点 100 / 100
結果
AC × 3
セット名 テストケース
All 10_random_to_kyo.txt, 20_noised_tokyoto.txt, 99_teuchi.txt
ケース名 結果 実行時間 メモリ
10_random_to_kyo.txt AC 31 ms 1136 KiB
20_noised_tokyoto.txt AC 31 ms 1120 KiB
99_teuchi.txt AC 32 ms 1040 KiB