Submission #5337799


Source Code Expand

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i) sort((i).begin(),(i).end(), greater<int>());
#define F first
#define S second
constexpr auto INF = 1000000000;
constexpr auto LLINF = 9223372036854775807;
constexpr auto mod = 1000000007;
int main() {

	int t;
	cin >> t;
	FOR(i, t) {
		string s;
		cin >> s;
		vector<pair<int, int>> a;
		if (s.length() < 5) {
			cout << 0 << endl;
			continue;
		}
		FOR(j, s.length() - 4) {
			if (s.substr(j, 5) == "kyoto" || s.substr(j, 5) == "tokyo") {
				a.push_back({ j + 4, j });
			}
		}
		SORT(a);
		int ans = 0, last = -1;
		FOR(j, a.size()) {
			if (a[j].S > last) {
				ans++;
				last = a[j].F;
			}
		}
		cout << ans << endl;
	}

	return 0;
}

Submission Info

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