Code Submission Evaluation System Login

HIIT Open 2018

Start:2018-05-26 11:00:00
End:2018-05-26 16:00:00
 

Tasks | Messages | Scoreboard | Statistics


CSES - HIIT Open 2018 - Results
History
2018-05-26 13:06:13
Task:HIIT Generation
Sender:HIIT AND RUN
Submission time:2018-05-26 13:06:13
Language:C++
Status:READY
Result:ACCEPTED

Test results

testverdicttime (s)
#1ACCEPTED0.07 / 1.00details
#2ACCEPTED0.30 / 1.00details
#3ACCEPTED0.05 / 1.00details
#4ACCEPTED0.01 / 1.00details

Compiler report

input/code.cpp:16:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main () {
       ^

Code

#include <bits/stdc++.h>

using namespace std;

set<int> H, I, T;

deque<pair<char,int>> pino;

void push_hiit(int seq) {
    pino.push_back({'T', seq});
    pino.push_back({'I', seq});
    pino.push_back({'I', seq});
    pino.push_back({'H', seq});
}

main () {
 
    int n;
    cin >> n;
    
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        
        if (s == "H")
            H.insert(i+1);
        
        if (s == "I")
            I.insert(i+1);
        
        if (s == "T")
            T.insert(i+1);
    }
    
    push_hiit(0);
    
    while (pino.size()) {
     
        auto pari = pino.back();
        pino.pop_back();
        
        int t = pari.second;
        char c = pari.first;
        
        int next = 0;
        
        if (c == 'H') {
            auto inext = H.upper_bound(t);
            if (inext != H.end())
                next = *inext;
        }
        
        if (c == 'I') {
            auto inext = I.upper_bound(t);
            if (inext != I.end())
                next = *inext;
        }
        
        if (c == 'T') {
            auto inext = T.upper_bound(t);
            if (inext != T.end())
                next = *inext;
        }
        
        if (next == 0) {
            cout << c;
        } else {
            push_hiit(next);
        }
        
    }
    
    cout << endl;
    
    
}

Test details

Test 1

Verdict: ACCEPTED

input
17
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
I
view   save

correct output
HHHHHHHHHHHHHHHHHHIITHIITTHHII...
view   save

user output
HHHHHHHHHHHHHHHHHHIITHIITTHHII...
view   save

Test 2

Verdict: ACCEPTED

input
333332
H
H
H
H
H
H
H
H
H
H
H
H
H
H
H
H
H
H
H
...
view   save

correct output
HIITIITIITIITIITIITIITIITIITII...
view   save

user output
HIITIITIITIITIITIITIITIITIITII...
view   save

Test 3

Verdict: ACCEPTED

input
24
H
T
H
T
H
T
H
T
H
T
H
T
H
T
H
T
H
T
H
...
view   save

correct output
HIIHIITIIHIIHIITIIHIITIIHIIHII...
view   save

user output
HIIHIITIIHIIHIITIIHIITIIHIIHII...
view   save

Test 4

Verdict: ACCEPTED

input
0
view   save

correct output
HIIT
view   save

user output
HIIT
view   save