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 11:33:05
Task:HIIT Generation
Sender:Karhukopla
Submission time:2018-05-26 11:33:05
Language:C++
Status:READY
Result:ACCEPTED

Test results

testverdicttime (s)
#1ACCEPTED0.24 / 1.00details
#2ACCEPTED0.32 / 1.00details
#3ACCEPTED0.20 / 1.00details
#4ACCEPTED0.01 / 1.00details

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
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