Task: | HIIT Generation |
Sender: | Puhi~ |
Submission time: | 2018-05-26 14:21:13 +0300 |
Language: | C++ |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.06 s | details |
#2 | ACCEPTED | 0.11 s | details |
#3 | ACCEPTED | 0.05 s | details |
#4 | ACCEPTED | 0.01 s | details |
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 ... |
correct output |
---|
HHHHHHHHHHHHHHHHHHIITHIITTHHII... |
user output |
---|
HHHHHHHHHHHHHHHHHHIITHIITTHHII... |
Test 2
Verdict: ACCEPTED
input |
---|
333332 H H H H ... |
correct output |
---|
HIITIITIITIITIITIITIITIITIITII... |
user output |
---|
HIITIITIITIITIITIITIITIITIITII... |
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 |