Submission #532946


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
int f(string s) {
	int r = 0;
	int p = 0;
	for (;;) {
		auto i = s.find("tokyo", p);
		auto j = s.find("kyoto", p);
		if (i == string::npos && j == string::npos) break;
		auto k = min(i, j);
		p = k + 5;
		++ r;
	}
	return r;
}
int main() {
	int T;
	cin >> T;
	for (int tt = 0; tt < T; ++ tt) {
		string s;
		cin >> s;
		cout << f(s) << endl;
	}
}

Submission Info

Submission Time
Task A - 東京都
User hasi
Language C++ (GCC 4.9.2)
Score 0
Code Size 418 Byte
Status CE

Compile Error

./Main.cpp: In function ‘int f(std::string)’:
./Main.cpp:7:8: error: ‘i’ does not name a type
   auto i = s.find("tokyo", p);
        ^
./Main.cpp:8:8: error: ‘j’ does not name a type
   auto j = s.find("kyoto", p);
        ^
./Main.cpp:9:7: error: ‘i’ was not declared in this scope
   if (i == string::npos && j == string::npos) break;
       ^
./Main.cpp:9:28: error: ‘j’ was not declared in this scope
   if (i == string::npos && j == string::npos) break;
                            ^
./Main.cpp:10:8: error: ‘k’ does not name a type
   auto k = min(i, j);
        ^
./Main.cpp:11:7: error: ‘k’ was not declared in this scope
   p = k + 5;
       ^