CSES - HIIT Open 2017 - Results
Submission details
Task:HIIT game
Sender:Nää jäbät
Submission time:2017-05-27 11:33:16 +0300
Language:C++
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.05 sdetails
#2ACCEPTED0.04 sdetails
#3ACCEPTED0.06 sdetails
#4ACCEPTED0.07 sdetails
#5ACCEPTED0.09 sdetails
#6ACCEPTED0.08 sdetails
#7ACCEPTED0.11 sdetails
#8ACCEPTED0.13 sdetails
#9ACCEPTED0.11 sdetails
#100.04 sdetails
#11ACCEPTED0.04 sdetails
#12ACCEPTED0.04 sdetails
#13ACCEPTED0.04 sdetails
#140.05 sdetails
#150.03 sdetails
#16ACCEPTED0.06 sdetails
#17ACCEPTED0.06 sdetails
#180.07 sdetails
#19ACCEPTED0.04 sdetails
#200.03 sdetails
#210.04 sdetails
#220.06 sdetails
#23ACCEPTED0.05 sdetails
#240.02 sdetails
#25ACCEPTED0.06 sdetails
#260.07 sdetails
#270.04 sdetails
#280.04 sdetails
#29ACCEPTED0.04 sdetails

Compiler report

input/code.cpp: In function 'int f(int, int)':
input/code.cpp:13:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if (e[i] || i == s.length() - 4) return NIL;
                                   ^
input/code.cpp: In function 'int main()':
input/code.cpp:72:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < s.length() - 4; i++) {
                                      ^

Code

#include <bits/stdc++.h>

#define ll long long

using namespace std;

string s;
int e[1111111];
int NIL = 13371337;
int am = 0;

int f (int i, int k) {
    if (e[i] || i == s.length() - 4) return NIL;
    e[i] = 1;
    if (k == 0) {
        if (s[i] != 'H') e[i] = 0;
        if (s[i] != 'H') return NIL;
        if (s[i + 1] == 'H') {
            int x = f(i + 1, 0);
            if (x == NIL) e[i] = 0;
            if (x == NIL) return NIL;
            int y = f(x + 1, k + 1);
            if (y == NIL) e[i] = 0;
            return y;
        } else {
            int x = f(i + 1, k + 1);
            if (x == NIL) e[i] = 0;
            return x;
        }
    } else if (k == 3) {
        if (s[i] != 'T') e[i] = 0;
        if (s[i] != 'T') return NIL;
        am++;;
        return i;
    } else {
        if (s[i] != 'I') e[i] = 0;
        if (s[i] != 'I') return NIL;
        if (k == 1) {
            if (s[i + 1] == 'H') {
                int x = f(i + 1, 0);
                if (x == NIL) e[i] = 0;
                if (x == NIL) return NIL;
                int y = f(x + 1, k + 1);
                if (y == NIL) e[i] = 0;
                return y;
            } else {
                int x = f(i + 1, k + 1);
                if (x == NIL) e[i] = 0;
                return x;
            }
        } else {
            if (s[i + 1] == 'H') {
                int x = f(i + 1, 0);
                if (x == NIL) e[i] = 0;
                if (x == NIL) return NIL;
                
                int y = f(x + 1, k + 1);
                if (y == NIL) e[i] = 0;
                return y;
            } else {
                int x = f(i + 1, k + 1);
                if (x == NIL) e[i] = 0;
                return x;
            }
        }
    }
}

int main () {
    cin>>s;
    s += "####";
    for (int i = 0; i < s.length() - 4; i++) {
        if (s[i] == 'H') {
            f(i, 0);
        }
    }
    if (am % 2) cout<<"Uolevi"<<endl;
    else cout<<"Maija"<<endl;
}

Test details

Test 1

Verdict: ACCEPTED

input
HIIT

correct output
Uolevi

user output
Uolevi

Test 2

Verdict: ACCEPTED

input
TIIH

correct output
Maija

user output
Maija

Test 3

Verdict: ACCEPTED

input
HIITHIIT

correct output
Maija

user output
Maija

Test 4

Verdict: ACCEPTED

input
HIHIHIHI

correct output
Maija

user output
Maija

Test 5

Verdict: ACCEPTED

input
HIITHIITHIITHIITHIITHIITHIITHI...

correct output
Uolevi

user output
Uolevi

Test 6

Verdict: ACCEPTED

input
HIITHIITHIITHIITHIITHIITHIITHI...

correct output
Maija

user output
Maija

Test 7

Verdict: ACCEPTED

input
HITIHITIHITIHITIHITIHITIHITIHI...

correct output
Maija

user output
Maija

Test 8

Verdict: ACCEPTED

input
HIHIHIHIHIHIHIHIHIHIHIHIHIHIHI...

correct output
Uolevi

user output
Uolevi

Test 9

Verdict: ACCEPTED

input
HIHIHIHIHIHIHIHIHIHIHIHIHIHIHI...

correct output
Maija

user output
Maija

Test 10

Verdict:

input
THIITIHIIHHTIITIIITITTTHIHITHH...

correct output
Maija

user output
Uolevi

Test 11

Verdict: ACCEPTED

input
HIHHHIITHTHIITIIHIIHIITITTIHII...

correct output
Uolevi

user output
Uolevi

Test 12

Verdict: ACCEPTED

input
HTHIITHHHHIHITIIIHIITHHIIHIITT...

correct output
Uolevi

user output
Uolevi

Test 13

Verdict: ACCEPTED

input
IHIITIHHHIIHIITHHHIITHIITIHIIT...

correct output
Maija

user output
Maija

Test 14

Verdict:

input
HHHIHHHIITHIITHHIHIITHIIIITHII...

correct output
Uolevi

user output
Maija

Test 15

Verdict:

input
ITTHHIIHIITTIHIIHTIHIITHHITITT...

correct output
Uolevi

user output
Maija

Test 16

Verdict: ACCEPTED

input
HIIIHHITITTTHHIIHTIHIITITTITHI...

correct output
Uolevi

user output
Uolevi

Test 17

Verdict: ACCEPTED

input
HIITHHIITHHITHIITITIITHIITHHII...

correct output
Uolevi

user output
Uolevi

Test 18

Verdict:

input
HIIHIITTTHHIITIIHHITITTHHIIITH...

correct output
Uolevi

user output
Maija

Test 19

Verdict: ACCEPTED

input
IHHIITHIITHTHHIITHIHHIIHTIHHHI...

correct output
Maija

user output
Maija

Test 20

Verdict:

input
HIITHIIHIITTHIITHHHIIHTHIHIHII...

correct output
Uolevi

user output
Maija

Test 21

Verdict:

input
THHTHIITHHHIITIITHHIITIHIITIHI...

correct output
Uolevi

user output
Maija

Test 22

Verdict:

input
IHIITIHIHIIHTHHIIIITTTTHHIITHI...

correct output
Maija

user output
Uolevi

Test 23

Verdict: ACCEPTED

input
HIIIHIITTHIIHIIITTHHTHHHHHIIHI...

correct output
Uolevi

user output
Uolevi

Test 24

Verdict:

input
HIHHIHIHIITHIIITITIHIHIITITIHI...

correct output
Maija

user output
Uolevi

Test 25

Verdict: ACCEPTED

input
HIITHIHIHIIHIITTHIHHIITIITIHII...

correct output
Uolevi

user output
Uolevi

Test 26

Verdict:

input
HHHITITHTHHIHTITIHHIITHIITIITH...

correct output
Maija

user output
Uolevi

Test 27

Verdict:

input
IHIITHTHIITHIHIHHTHIITIHIHITIT...

correct output
Maija

user output
Uolevi

Test 28

Verdict:

input
HIITIITHIHHIITIHHIHIITITHIITHH...

correct output
Uolevi

user output
Maija

Test 29

Verdict: ACCEPTED

input
HHHHIITIITHTITHIHIHITITHHIITII...

correct output
Uolevi

user output
Uolevi