Submission #3686747


Source Code Expand

#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<string> s(n);
  string t = "tokyo";
  string k = "kyoto";
  vector<int> ans(n);
  REP(i,n){
    cin >> s[i];
    ans[i] = 0;
  }
  REP(i,n){
    //s[i].substr(j,t.size())cout << s[i] << endl;
    REP(j,s[i].size()){
      //cout << s[i].substr(j,t.size()) << endl;
      if(s[i].substr(j,t.size()) == t){
          ans[i]++;
          j += t.size() -1 ;
      }
      else if(s[i].substr(j,k.size()) == k){
          ans[i]++;
          j += k.size()-1;
      }
    }
  }
  REP(i,n) cout << ans[i] << endl;
}

Submission Info

Submission Time
Task A - 東京都
User Bondo416
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1175 Byte
Status AC
Exec Time 2 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 2 ms 256 KB
20_noised_tokyoto.txt AC 2 ms 256 KB
99_teuchi.txt AC 2 ms 256 KB