Task: | HIIT Generation |
Sender: | HIIT AND RUN |
Submission time: | 2018-05-26 13:06:13 +0300 |
Language: | C++ |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.07 s | details |
#2 | ACCEPTED | 0.30 s | details |
#3 | ACCEPTED | 0.05 s | details |
#4 | ACCEPTED | 0.01 s | details |
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 ... |
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 |