Code Submission Evaluation System Login

CSES - HIIT Open 2017

HIIT Open 2017

Contest start:2017-05-27 11:00:00
Contest end:2017-05-27 16:00:00

Task list | Submit code | Submissions | Messages | Scoreboard


History
2017-05-27 12:36:40
2017-05-27 12:28:49
Task:HIIT game
Sender:Proudly div 2
Submission time:2017-05-27 12:36:40
Status:READY
Result:ACCEPTED

Show test data

Code

#include <iostream>
#include <vector>

using namespace std;

int main() {
	string s;

	cin >> s;

	int c = 0;

	vector<int> iCount;

	for(char ch : s) {
			//cout << ch;
		switch(ch) {
		case 'I':
			if(!iCount.empty()) {
				iCount.back()++;
				//cout << "iCount " << iCount.size() << " now " << iCount.back() << endl;
			}
			break;
		case 'H': 
			iCount.push_back(0);
			//cout << "new iCount " << iCount.size() << endl;
			break;
		case 'T':
			if(iCount.empty()) break;
			if(iCount.back() == 2) {
				c++;
				//cout << "HIIT " << c << " at depth " << iCount.size() << endl;	
				iCount.pop_back();
			} else {
				//cout << iCount.back() << " I's wrong, scrapping" << endl;
				iCount.clear();
			}
			break;
		}
	}
	
	cout << ((c&1) ? "Uolevi" : "Maija") << endl;
}