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 13:00:50
2018-05-26 12:49:51
Task:HIIT Generation
Sender:KnowYourArchitecture
Submission time:2018-05-26 13:00:50
Language:C++
Status:READY
Result:ACCEPTED

Test results

testverdicttime (s)
#1ACCEPTED0.07 / 1.00details
#2ACCEPTED0.14 / 1.00details
#3ACCEPTED0.05 / 1.00details
#4ACCEPTED0.01 / 1.00details

Code

#include <bits/stdc++.h>

using namespace std;

int n;
char chr[10000001];
int nexti[4][10000001];

void r(int i) {
	for(auto c : string("HIIT")) {
		int ni = -1;
		if(i < n) {
			if(c == 'H') ni = nexti[0][i];
			if(c == 'I') ni = nexti[1][i];
			if(c == 'T') ni = nexti[2][i];
		}

		if(ni == -1) {
			cout << c;
		} else {
			r(ni+1);
		}
	}
}

int main() {
	cin >> n;
	for(int j=0;j<n;j++) {
		cin >> chr[j];
	}
	int ph=-1,pi=-1,pt=-1;
	for(int j=n-1;j>=0;j--) {
		if(chr[j] == 'H') ph=j;
		if(chr[j] == 'I') pi=j;
		if(chr[j] == 'T') pt=j;
		nexti[0][j] = ph;
		nexti[1][j] = pi;
		nexti[2][j] = pt;
	}
	r(0);
	cout << endl;
	return 0;
}

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