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:24:11
Task:HIIT game
Sender:KnowYourArchitecture
Submission time:2017-05-27 12:24:11
Status:READY
Result:ACCEPTED

Show test data

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:20:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<s.length();i++) {
                            ^

Code

#include <bits/stdc++.h>

using namespace std;

bool valid(vector<char>& s) {
    if(s.size() < 4) {
        return false;
    }
    int n = s.size();
    return s[n-1] == 'T' && s[n-2] == 'I' && s[n-3] == 'I' && s[n-4] == 'H';
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    vector<char> stack;
    int cnt = 0;
    for(int i=0;i<s.length();i++) {
        stack.push_back(s[i]);
        if(valid(stack)) {
            cnt += 1;
            for(int j=0;j<4;j++) {
                stack.pop_back();
            }
        }
    }
    if(cnt%2 == 0) {
        cout << "Maija" << endl;
    } else {
        cout << "Uolevi" << endl;
    }
    return 0;
}