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 14:21:13
2018-05-26 11:54:16
2018-05-26 11:32:54
2018-05-26 11:26:35
2018-05-26 11:16:28
Task:HIIT Generation
Sender:Puhi~
Submission time:2018-05-26 14:21:13
Language:C++
Status:READY
Result:ACCEPTED

Test results

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

Compiler report

input/code.cpp: In function 'void r(char, int)':
input/code.cpp:21:37: warning: 'tablesize' may be used uninitialized in this function [-Wmaybe-uninitialized]
         while (i + step < tablesize && table[i + step] <= y)  {
                ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~

Code

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

using namespace std;

int h[1000000];
int ii[1000000];
int t[1000000];
int hs, is, ts;

void r(char a, int y) {

    int *table;
    int tablesize;
    if (a == 'H') {table = h; tablesize = hs;}
    if (a == 'I') {table = ii; tablesize = is;}
    if (a == 'T') {table = t; tablesize = ts;}
    
    int i = -1;
    for (int step = 100000; step > 0; step /= 2) {
        while (i + step < tablesize && table[i + step] <= y)  {
            i += step;
        }
    }

    if (i + 1 != tablesize) {
        r('H', table[i+1]);
        r('I', table[i+1]);
        r('I', table[i+1]);
        r('T', table[i+1]);
        return;
    }

    putchar_unlocked(a);
}

int main() {
    int n;
    cin >> n;
    
    hs = is = ts = 0;
    for (int i = 0; i < n; i++) {
        char tmp;
        cin >> tmp;
        if (tmp == 'H') { h[hs++] = i;}
        if (tmp == 'I') { ii[is++] = i;}
        if (tmp == 'T') { t[ts++] = i;}
    }
    
    r('H', -1);
    r('I', -1);
    r('I', -1);
    r('T', -1);
    putchar_unlocked('\n');
}

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