Task: | HIIT Generation |
Sender: | Karhukopla |
Submission time: | 2018-05-26 11:33:05 +0300 |
Language: | C++ |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.24 s | details |
#2 | ACCEPTED | 0.32 s | details |
#3 | ACCEPTED | 0.20 s | details |
#4 | ACCEPTED | 0.01 s | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:52:15: warning: array subscript has type 'char' [-Wchar-subscripts] swap(q, ns[c]); ^ input/code.cpp:53:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int i = 0; i < q.size(); i++) { ~~^~~~~~~~~~
Code
#include <bits/stdc++.h>#define ll long long#define lll __int128#define pii pair<int, int>#define M 1000000007#define N (1<<20)using namespace std;struct node {char v;vector<node*> ch;node (char c) {v = c;ch = {};}};vector<node*> ns[255];void push (node* &n) {n->ch.push_back(new node('H'));n->ch.push_back(new node('I'));n->ch.push_back(new node('I'));n->ch.push_back(new node('T'));ns['H'].push_back(n->ch[0]);ns['I'].push_back(n->ch[1]);ns['I'].push_back(n->ch[2]);ns['T'].push_back(n->ch[3]);}void print (node* n) {if (n->ch.empty()) cout<<(n->v);else {print(n->ch[0]);print(n->ch[1]);print(n->ch[2]);print(n->ch[3]);}}int main () {node* root = new node('*');push(root);int n;cin>>n;while (n --> 0) {char c;cin>>c;vector<node*> q;swap(q, ns[c]);for (int i = 0; i < q.size(); i++) {push(q[i]);}}print(root);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 |