Task: | HIIT Generation |
Sender: | Tefyn virallinen maajoukkue |
Submission time: | 2018-05-26 13:44:36 +0300 |
Language: | C++ |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.06 s | details |
#2 | ACCEPTED | 0.18 s | details |
#3 | ACCEPTED | 0.06 s | details |
#4 | ACCEPTED | 0.01 s | details |
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 ... |
correct output |
---|
HHHHHHHHHHHHHHHHHHIITHIITTHHII... |
user output |
---|
HHHHHHHHHHHHHHHHHHIITHIITTHHII... |
Test 2
Verdict: ACCEPTED
input |
---|
333332 H H H H ... |
correct output |
---|
HIITIITIITIITIITIITIITIITIITII... |
user output |
---|
HIITIITIITIITIITIITIITIITIITII... |
Test 3
Verdict: ACCEPTED
input |
---|
24 H T H T ... |
correct output |
---|
HIIHIITIIHIIHIITIIHIITIIHIIHII... |
user output |
---|
HIIHIITIIHIIHIITIIHIITIIHIIHII... |
Test 4
Verdict: ACCEPTED
input |
---|
0 |
correct output |
---|
HIIT |
user output |
---|
HIIT |