Submission #2152501


Source Code Expand

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
using namespace std;

typedef pair<int,int> P;
int T;
string S;
vector<P> v;

int main(){
	cin >> T;
	for(int i=0;i<T;i++){
		cin >> S;
		int ans = 0,last = -1;
		if(S.size()>=5){
			for(int j=0;j<S.size()-4;j++){
				string s = S.substr(j,5);
				if(s=="kyoto" || s=="tokyo"){
					v.push_back(P(j+4,j));
				}			
			}
			sort(v.begin(),v.end());
			for(int j=0;j<v.size();j++){
				if(last<v[j].second){
					ans++;
					last = v[j].first;
				}
			}
		}
		cout << ans << endl;
		v.clear();
	}
}

Submission Info

Submission Time
Task A - 東京都
User idsigma
Language C++14 (GCC 5.4.1)
Score 100
Code Size 628 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