Submission #2638304


Source Code Expand

// {{{
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#if __cplusplus >= 201103
#include <numeric>
#endif
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()

//#if __cplusplus >= 201103
typedef long long ll;
//#endif
typedef pair<int, int> P;
typedef pair<int, P> IP;

int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

const int INF = 100000000;
//#if __cplusplus >= 201103
const ll LINF = 10000000000000000ll;
//#endif
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
// }}}

string s;

void init()
{
}


void solve()
{
    int ans = 0;
    size_t pos = 0;
    while(true){
        size_t pos1 = s.find("tokyo", pos);
        size_t pos2 = s.find("kyoto", pos);
        if(pos1 != string::npos && pos2 != string::npos) pos = min(pos1, pos2);
        else if(pos1 != string::npos) pos = pos1;
        else if(pos2 != string::npos) pos = pos2;
        else break;
        pos += 5;
        ans++;
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    REP(i, n){
        cin >> s;
        solve();
    }
    return 0;
}

// vim:set foldmethod=marker:

Submission Info

Submission Time
Task A - 東京都
User rrrccc
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1699 Byte
Status AC
Exec Time 1 ms
Memory 256 KB

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 1 ms 256 KB
20_noised_tokyoto.txt AC 1 ms 256 KB
99_teuchi.txt AC 1 ms 256 KB