CSES - HIIT Open 2018 - Results
Submission details
Task:HIIT Generation
Sender:Robotiimi
Submission time:2018-05-26 11:59:39 +0300
Language:C++
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.02 sdetails
#2--details
#3ACCEPTED0.03 sdetails
#4ACCEPTED0.01 sdetails

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:22:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j=0; j<r1.size(); j++) {
                       ~^~~~~~~~~~
input/code.cpp:32:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j=0; j<r2.size(); j++) {
                       ~^~~~~~~~~~

Code

#include <bits/stdc++.h>
#include <string>

using namespace std;


int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);

int n;
cin >> n;
string r1 = "HIIT";
string r2 = "HIIT";
char a;
char b;

for (int i=0; i<n; i++) {
    cin >> a;
    if (i%2==0) {
        r2 = "";
        for (int j=0; j<r1.size(); j++) {            
            b = r1[j];
            if (b==a) {
                r2 += "HIIT"; 
            } else {
                r2 += b;
            }
        }
    } else {
        r1 = "";
        for (int j=0; j<r2.size(); j++) {            
            b = r2[j];
            if (b==a) {
                r1 += "HIIT";
            } else {
                r1 += b;
            }
        }
    
    }
}
if (r1.size() < r2.size()) {
    cout << r2 << "\n";
} else {
    cout << r1 << "\n";
}
}

Test details

Test 1

Verdict: ACCEPTED

input
17
I
I
I
I
...

correct output
HHHHHHHHHHHHHHHHHHIITHIITTHHII...

user output
HHHHHHHHHHHHHHHHHHIITHIITTHHII...

Test 2

Verdict:

input
333332
H
H
H
H
...

correct output
HIITIITIITIITIITIITIITIITIITII...

user output
(empty)

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