Submission #532931


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<to;x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int T;
int dp[1010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>T;
	while(T--) {
		cin>>s;
		FOR(i,s.size()) {
			dp[i+1]=dp[i];
			if(i>=4) {
				if(s.substr(i-4,5)=="tokyo" || s.substr(i-4,5)=="kyoto") {
					dp[i+1]=max(dp[i+1],dp[i+1-5]+1);
				}
			}
		}
		cout<<dp[s.size()]<<endl;
		
		
	}
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}

Submission Info

Submission Time
Task A - 東京都
User kmjp
Language C++11 (GCC 4.9.2)
Score 100
Code Size 1004 Byte
Status AC
Exec Time 36 ms
Memory 1080 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 36 ms 1052 KB
20_noised_tokyoto.txt AC 34 ms 1080 KB
99_teuchi.txt AC 29 ms 1004 KB