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 11:23:27
2018-05-26 11:22:47
Task:HIIT Generation
Sender:Ukkonen Fan Club
Submission time:2018-05-26 11:23:27
Language:C++
Status:READY
Result:ACCEPTED

Test results

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

Code

#include<bits/stdc++.h>
using namespace std;
int n;

int H[1222333];
int I[1222333];
int T[1222333];
char t[1222333];


void r(int p){
    if (H[p]==n+1) cout << "H";
    else r(H[p]);
    if (I[p]==n+1) cout << "II";
    else r(I[p]), r(I[p]);
    if (T[p]==n+1) cout << "T";
    else r(T[p]);
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin >> n;
    for (int i=0;i<n;++i) cin >> t[i];
    H[n]=n+1;
    I[n]=n+1;
    T[n]=n+1;
    for (int i=n-1;i>=0;--i){
        H[i]=H[i+1];
        I[i]=I[i+1];
        T[i]=T[i+1];
        if (t[i]=='H') H[i]=i+1;
        if (t[i]=='I') I[i]=i+1;
        if (t[i]=='T') T[i]=i+1;
    }
    r(0);
    cout << "\n";
}

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