Submission #3266652


Source Code Expand

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <stack>
#include <queue>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)

//変数
int T;
vector<string> vec;
string tokyo = "tokyo", kyoto = "kyoto";

//解法
void solve() {

	rep(i, T) {

		int ans=0;
		int size = vec[i].size();
		rep(j, size-4) {

			bool flag = true;
			rep(k, 5) {
				if (vec[i][j + k] == tokyo[k]) {

				}
				else {
					flag = false;
					break;
				}
			}

			if (flag == true) {
				j += 4;
				ans++;
				continue;
			}

			flag = true;
			rep(k, 5) {
				if (vec[i][j + k] == kyoto[k]) {

				}
				else {
					flag = false;
					break;
				}
			}

			if (flag == true) {
				j += 4;
				ans++;
				continue;
			}

		}

		cout << ans << endl;

	}

	return;
}

int main() {
	//入力
	cin >> T;
	vec.resize(T);
	rep(i, T) cin >> vec[i];
	solve();
	//cout << endl;
	return 0;
}

Submission Info

Submission Time
Task A - 東京都
User huma17
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1054 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 1 ms 256 KB