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:36:20
Task:HIIT Generation
Sender:Oispa nutellaa
Submission time:2018-05-26 13:36:20
Language:C++
Status:READY
Result:ACCEPTED

Test results

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

Code

#include <bits/stdc++.h>
#define ull unsigned long long

using namespace std;

int n;
vector<char> movet;
set<int> H, I, T; // Move indeksit
char cha;
stack<pair<string, int>> stk;

int main() {
	cin >> n;
	for(int i=0; i<n; i++) {
		cin >> cha;
		movet.push_back(cha);
		if(cha=='H')
			H.insert(i);
		else if(cha=='I')
			I.insert(i);
		else
			T.insert(i);
	}
	stk.push(make_pair("T", -1));
	stk.push(make_pair("I", -1));
	stk.push(make_pair("I", -1));
	stk.push(make_pair("H", -1));
	while(!stk.empty()) {
		auto p = stk.top();
		stk.pop();
		if(p.first=="H") {
			auto it = H.upper_bound(p.second);
			if(it==H.end()) {
				cout << p.first;
			} else {
					stk.push(make_pair("T", *it));
					stk.push(make_pair("I", *it));
					stk.push(make_pair("I", *it));
					stk.push(make_pair("H", *it));
			}
		} else if(p.first=="I") {
			auto it = I.upper_bound(p.second);
			if(it==I.end()) {
				cout << p.first;
			} else {
					stk.push(make_pair("T", *it));
					stk.push(make_pair("I", *it));
					stk.push(make_pair("I", *it));
					stk.push(make_pair("H", *it));
			}
		} else {
			auto it = T.upper_bound(p.second);
			if(it==T.end()) {
				cout << p.first;
			} else {
					stk.push(make_pair("T", *it));
					stk.push(make_pair("I", *it));
					stk.push(make_pair("I", *it));
					stk.push(make_pair("H", *it));
			}
		}
	}



}

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