CSES - HIIT Open 2017 - Results
Submission details
Task:HIIT game
Sender:IOG
Submission time:2017-05-27 15:08:11 +0300
Language:C++
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.06 sdetails
#2ACCEPTED0.07 sdetails
#3ACCEPTED0.05 sdetails
#4ACCEPTED0.05 sdetails
#5--details
#6--details
#7ACCEPTED0.05 sdetails
#8--details
#9--details
#100.04 sdetails
#11ACCEPTED0.04 sdetails
#12ACCEPTED0.07 sdetails
#13ACCEPTED0.05 sdetails
#14ACCEPTED0.03 sdetails
#150.05 sdetails
#16ACCEPTED0.06 sdetails
#170.03 sdetails
#18ACCEPTED0.06 sdetails
#190.03 sdetails
#200.06 sdetails
#210.05 sdetails
#220.04 sdetails
#23ACCEPTED0.06 sdetails
#24ACCEPTED0.04 sdetails
#25ACCEPTED0.04 sdetails
#26ACCEPTED0.05 sdetails
#270.06 sdetails
#280.05 sdetails
#290.04 sdetails

Code

#include <bits/stdc++.h>

using namespace std;



inline int findh(string& s, unordered_set<int>& set)
{
    const char* hiit = "HIIT";
    int hidx = 0;
    unsigned int i = 0;
    int space = 0;
    
    //for (auto x : set)
    //    cout << x << endl;
    
    
    for (;i < s.size();)
    {
        if (set.count((int)i))
            space += 4;
        
        if (space == 0)
        {
            if (s[i] == hiit[hidx])
            {
                hidx++;
            }
            else 
            {
                hidx = 0;
                if (s[i] == hiit[hidx])
                    hidx++;
            }
        }
        
        //cout << hidx << endl;
        
        if (hidx == 4)
            return (i - 3);
        
        
        i++;
        if (space > 0)
        --space;
    }
    
    return -1;
}

int main(void)
{
 cin.sync_with_stdio(0);
 cin.tie(0);
 string s;
 
 cin >> s;
 
 unordered_set<int> set; 
 
 //int start = 0;
 int player = 0;
 
 for(;;)
 {
     //cout << s << endl;
     int p = findh(s, set);
     //cout << start << "\n";
     //cout << "p " <<  p << endl;
     if (p != -1)
     {
         player += 1;
         
         set.insert(p);
         
     }else {
         if (player % 2 == 1)
             cout << "Uolevi" << endl;
         else cout << "Maija" << endl;
      
         return 0;
     }
}
}

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:

input
HIITHIITHIITHIITHIITHIITHIITHI...

correct output
Uolevi

user output
(empty)

Test 6

Verdict:

input
HIITHIITHIITHIITHIITHIITHIITHI...

correct output
Maija

user output
(empty)

Test 7

Verdict: ACCEPTED

input
HITIHITIHITIHITIHITIHITIHITIHI...

correct output
Maija

user output
Maija

Test 8

Verdict:

input
HIHIHIHIHIHIHIHIHIHIHIHIHIHIHI...

correct output
Uolevi

user output
(empty)

Test 9

Verdict:

input
HIHIHIHIHIHIHIHIHIHIHIHIHIHIHI...

correct output
Maija

user output
(empty)

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: ACCEPTED

input
HHHIHHHIITHIITHHIHIITHIIIITHII...

correct output
Uolevi

user output
Uolevi

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:

input
HIITHHIITHHITHIITITIITHIITHHII...

correct output
Uolevi

user output
Maija

Test 18

Verdict: ACCEPTED

input
HIIHIITTTHHIITIIHHITITTHHIIITH...

correct output
Uolevi

user output
Uolevi

Test 19

Verdict:

input
IHHIITHIITHTHHIITHIHHIIHTIHHHI...

correct output
Maija

user output
Uolevi

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: ACCEPTED

input
HIHHIHIHIITHIIITITIHIHIITITIHI...

correct output
Maija

user output
Maija

Test 25

Verdict: ACCEPTED

input
HIITHIHIHIIHIITTHIHHIITIITIHII...

correct output
Uolevi

user output
Uolevi

Test 26

Verdict: ACCEPTED

input
HHHITITHTHHIHTITIHHIITHIITIITH...

correct output
Maija

user output
Maija

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:

input
HHHHIITIITHTITHIHIHITITHHIITII...

correct output
Uolevi

user output
Maija