CSES - HIIT Open 2018 - Results
Submission details
Task:HIIT Generation
Sender:TreamDeam
Submission time:2018-05-26 15:55:52 +0300
Language:C++
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.05 sdetails
#2--details
#3ACCEPTED0.06 sdetails
#4ACCEPTED0.01 sdetails

Code

#include <iostream>
#include <string.h>
#include <stdio.h>

using namespace std;

int len;
char rep[2000000];
char ii[2000001] = {0};
int cnt = 0;



void write(char letter,int s) {
//cout << "wr\n";
    int a = 0;
    for (int i = s; i < len; i++) {
        if (letter == rep[i]) {
            write('H', i + 1);
            int ss = cnt;
            write('I', i + 1);
            int ee = cnt;
            int dif = ee - ss;
            for (int k = ss; k < ee; k++) {
                ii[k + dif] = ii[k];
            }
            cnt += dif;
            //write('I', i + 1);
            write('T', i + 1);
            a = 1;
            break;
        }
    }
    if (a == 0)
    //cout << letter;
    ii[cnt++] = letter;
}


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

    cin >> len;
    //scanf("%d\n", &len);
    char a;
    for (int i = 0; i < len; i++) {
        cin >> a;
        //scanf("%c\n", &a);
        rep[i] = a;
    }
    //cout << rep[0] << " " << rep[1] << "\n";
    write('H', 0);
    int start1 = cnt;
    write('I', 0);
    int end1 = cnt;
    //cout << start1 << " " << end1 << "\n";
    //for (int i = start1; i < end1; i++) {
    //    ii[i + dif] = ii[i];
    //}

    //memcpy(ii + start1, ii + end1, end1 - start1);
    //cnt = end1 + dif;
    //write('I', 0);
    write('T', 0);

    for (int i = 0; i < start1; i++) {
        //cout << ii[i];
        printf("%c", ii[i]);
    }
    for (int j = 0; j < 2; j++)
    for (int i = start1; i < end1; i++) {
        //if (ii[i] > 0)
        //cout << ii[i];
        printf("%c", ii[i]);
    }
    for (int i = end1; i < cnt; i++) {
        //cout << ii[i];
        printf("%c", ii[i]);
    }
    printf("\n");
    //cout << "\n";

    return 0;
}

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