Task: | HIIT Generation |
Sender: | barely div 2.8 burgeria |
Submission time: | 2018-05-26 12:35:41 +0300 |
Language: | C++ |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.25 s | details |
#2 | ACCEPTED | 0.33 s | details |
#3 | ACCEPTED | 0.17 s | details |
#4 | ACCEPTED | 0.01 s | details |
Compiler report
input/code.cpp: In function 'void update_list(std::vector<node*>&)': input/code.cpp:38:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int i = 0; i < cp.size(); i++) { ~~^~~~~~~~~~~
Code
#include <iostream> #include <cmath> #include <string> #include <vector> using namespace std; typedef long long LL; struct node { vector<node*> kids; char c; }; vector<node*> hs; vector<node*> is; vector<node*> ts; void expand(node * root) { node * h = new node(); h->c = 'H'; node * i1 = new node(); i1->c = 'I'; node * i2 = new node(); i2->c = 'I'; node * t = new node(); t->c = 'T'; root->kids.emplace_back(h); root->kids.emplace_back(i1); root->kids.emplace_back(i2); root->kids.emplace_back(t); hs.emplace_back(h); is.emplace_back(i1); is.emplace_back(i2); ts.emplace_back(t); } void update_list(vector<node*> & cp) { for (int i = 0; i < cp.size(); i++) { node * n = cp[i]; expand(n); } } void expand_char(char c) { if (c == 'H') { vector<node*> hcp = hs; hs.clear(); update_list(hcp); } if (c == 'I') { vector<node*> icp = is; is.clear(); update_list(icp); } if (c == 'T') { vector<node*> tcp = ts; ts.clear(); update_list(tcp); } } void solve(vector<char> & c, node * n) { if (n->kids.size() == 0) { c.emplace_back(n->c); return; } for (auto kid : n->kids) { solve(c, kid); } } int main() { int n; cin >>n; node * root = new node(); expand(root); for (int i = 0; i < n; i++) { char c; cin>>c; expand_char(c); } vector<char> c; solve(c, root); for (auto ch : c) cout << ch; } /* int main() { int n; cin >>n; int hc = 0; int ic = 0; int tc = 0; vector<char> v; vector<int> hnext(n); vector<int> inext(n); vector<int> tnext(n); for (int i = 0; i < n; i++) { char c; cin >> c; v.emplace_back(c); } int hprev = n; int iprev = n; int tprev = n; for (int i = n-1; i >= 0; i--) { if (v[i] == 'H') hprev = i; if (v[i] == 'I') iprev = i; if (v[i] == 'T') tprev = i; } } */
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 |