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:52:43
Task:HIIT game
Sender:kyy-kol
Submission time:2017-05-27 12:52:43
Status:READY
Result:ACCEPTED

Show test data

Compiler report

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

Code

#include <iostream>
#include <vector>
#include <string>

using namespace std;

string s;
vector<char> v;
int cur = 0;

int main() {
    cin >> s;
    
    for (int i = 0; i <= s.length(); ++i) {
        int cs = v.size();
        while (cs >= 4) {
            if (v[cs-4] == 'H' && v[cs-3] == 'I' && v[cs-2] == 'I' && v[cs-1] == 'T') {
                cur++;
                cur %= 2;
                for (int j = 0; j < 4; ++j) v.pop_back();
            }
            else break;
            cs = v.size();
        }
        if (i < s.length()) v.push_back(s[i]);
    }
    if (cur == 0) cout << "Maija\n";
    else cout << "Uolevi\n";
    return 0;
}