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:44:36
2018-05-26 12:58:16
2018-05-26 12:56:45
Task:HIIT Generation
Sender:Tefyn virallinen maajoukkue
Submission time:2018-05-26 13:44:36
Language:C++
Status:READY
Result:ACCEPTED

Test results

testverdicttime (s)
#1ACCEPTED0.06 / 1.00details
#2ACCEPTED0.18 / 1.00details
#3ACCEPTED0.06 / 1.00details
#4ACCEPTED0.01 / 1.00details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:34:16: warning: array subscript has type 'char' [-Wchar-subscripts]
         cc[m[i]]++;
                ^

Code

#include <bits/stdc++.h>

using namespace std;

int n; 
char m[10000000];

string expand(string c, int i, int hc, int ic, int tc){
    if(i == n)
        return c;
    if(c[0] == 'H' && hc == 0)
        return c;
    if(c[0] == 'I' && ic == 0)
        return c;
    if(c[0] == 'T' && tc == 0)
        return c;
    if(c[0] == m[i]){
        if(c[0] == 'H')
            hc--;
        if(c[0] == 'I')
            ic--;
        if(c[0] == 'T')
            tc--;
        return expand("H", i+1, hc, ic, tc)+expand("I", i+1, hc, ic, tc)+expand("I", i+1, hc, ic, tc)+expand("T", i+1, hc, ic, tc);
    }
    else
        return expand(c, i+1, hc, ic, tc);
}
int cc[256];
int main(){
    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> m[i];
        cc[m[i]]++;
    }
    cout << expand("H", 0, cc['H'], cc['I'], cc['T'])+expand("I", 0, cc['H'], cc['I'], cc['T'])+expand("I", 0, cc['H'], cc['I'], cc['T'])+expand("T", 0, cc['H'], cc['I'], cc['T']) << endl;
    return 0;
}

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