CSES - HIIT Open 2018 - Results
Submission details
Task:HIIT Generation
Sender:Robotiimi
Submission time:2018-05-26 11:49:14
Language:C++
Status:READY
Result:
Test results
testverdicttime
#10.02 sdetails
#20.04 sdetails
#30.01 sdetails
#4ACCEPTED0.01 sdetails

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:20:12: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
     if (i&1==0) {
           ~^~~
input/code.cpp:21:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j=0; j<r1.size(); j++) {
                       ~^~~~~~~~~~
input/code.cpp:30: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&1==0) {
        for (int j=0; j<r1.size(); j++) {            
            b = r1[j];
            if (b==a) {
                r2 += "HIIT"; 
            } else {
                r2 += b;
            }
        }
    } else {
        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:

input
17
I
I
I
I
...

correct output
HHHHHHHHHHHHHHHHHHIITHIITTHHII...

user output
HIITHHIITHIITTHHIITHIITTHHIITH...

Test 2

Verdict:

input
333332
H
H
H
H
...

correct output
HIITIITIITIITIITIITIITIITIITII...

user output
HIITHIITIITHIITIITHIITIITHIITI...

Test 3

Verdict:

input
24
H
T
H
T
...

correct output
HIIHIITIIHIIHIITIIHIITIIHIIHII...

user output
HIITHIITIITHIIHIITHIITIITHIIHI...

Test 4

Verdict: ACCEPTED

input
0

correct output
HIIT

user output
HIIT