Task: | Merkkijono |
Sender: | ISIMO66 |
Submission time: | 2017-10-04 22:47:07 +0300 |
Language: | C++ |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 100 |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.03 s | details |
#2 | ACCEPTED | 0.05 s | details |
#3 | ACCEPTED | 0.04 s | details |
#4 | ACCEPTED | 0.05 s | details |
#5 | ACCEPTED | 0.04 s | details |
#6 | ACCEPTED | 0.06 s | details |
#7 | ACCEPTED | 0.05 s | details |
#8 | ACCEPTED | 0.05 s | details |
#9 | ACCEPTED | 0.04 s | details |
#10 | ACCEPTED | 0.04 s | details |
Code
#include "stdio.h" #include "stdlib.h" int parse( char *, int *); int main ( int argc, char ** argv ){ //Get String char * str = (char *)malloc(sizeof(char)); int i = 0; str[0] = getchar(); while (1) { if (str[i]== EOF){ str[i] = '\0'; break; } i++; str = (char *)realloc(str, (i+2)*sizeof(char)); str[i] = getchar(); } int * index = (int *)malloc((i + 1) * sizeof(int)); int j = 0; while(str[j]){ index[j] = 1; j++; } index[j] = '\0'; //Parse String while(parse(str, index)) continue; //Print String j = 0; while(str[j]){ if (index[j]){ putchar(str[j]); } j++; } free(str); free(index); return 0; } int parse(char * str, int * index) { int i = 0; int change = 0; while (str[i]){ if (index[i] == 0){ i++; continue; } if (index[i + 1] == 1){ if ( str[i] == str[i+1]){ index[i] = 0; int ii = 1; while (str[i] == str[i+ii]){ index[i + ii] = 0; ii++; } change = 1; break; } } else { int ii = 1; while( index[i + ii] == 0){ if (!str[i+ii])break; ii++; } if (str[i] == str[i + ii]){ index[i] = 0; while (str[i] == str[i + ii]){ index[i + ii] = 0; ii++; } change = 1; break; } } i++; } if (change){ return 1; } else{ return 0; } }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
ABABABABABABABABABABABABABABAB... |
correct output |
---|
ABABABABABABABABABABABABABABAB... |
user output |
---|
ABABABABABABABABABABABABABABAB... |
Test 2
Verdict: ACCEPTED
input |
---|
AABBAABBAABBAABBAABBAABBAABBAA... |
correct output |
---|
(empty) |
user output |
---|
(empty) |
Test 3
Verdict: ACCEPTED
input |
---|
ABABABABABABABABABABABABABABAB... |
correct output |
---|
(empty) |
user output |
---|
(empty) |
Test 4
Verdict: ACCEPTED
input |
---|
BBABABBBBBAABBBABABABBBBAAABAB... |
correct output |
---|
BAB |
user output |
---|
BAB |
Test 5
Verdict: ACCEPTED
input |
---|
ACDCBBACDBBBACAACBBDBADBAABABA... |
correct output |
---|
ACDCACDADBADABACACDCADADABABCA... |
user output |
---|
ACDCACDADBADABACACDCADADABABCA... |
Test 6
Verdict: ACCEPTED
input |
---|
EETFHIJOGACDHMGVFJCMETMZDEITTR... |
correct output |
---|
TFHIJOGACDHMGVFJCMETMZDEIROTET... |
user output |
---|
TFHIJOGACDHMGVFJCMETMZDEIROTET... |
Test 7
Verdict: ACCEPTED
input |
---|
GOONLAHLYPRFCZKIKSJWAWWYJJPCDB... |
correct output |
---|
GNLAHLYPRFCZKIKSJWAYPCDNWYMRCE... |
user output |
---|
GNLAHLYPRFCZKIKSJWAYPCDNWYMRCE... |
Test 8
Verdict: ACCEPTED
input |
---|
PISHWMOTCDDZFRMYMOMYDYYGJZIQHS... |
correct output |
---|
PISHWMOTCZFRMYMOMYDGJZIQHSVAOK... |
user output |
---|
PISHWMOTCZFRMYMOMYDGJZIQHSVAOK... |
Test 9
Verdict: ACCEPTED
input |
---|
QUVVTPXAMWWODFXRONJODPGBTCISGM... |
correct output |
---|
QUTPXAMODFXRONJODPGBTCISGMVRBW... |
user output |
---|
QUTPXAMODFXRONJODPGBTCISGMVRBW... |
Test 10
Verdict: ACCEPTED
input |
---|
POXHAHYEZTLYNFSLABODMRNKDSKROZ... |
correct output |
---|
POXHAHYEZTLYNFSLABODMRNKDSKROZ... |
user output |
---|
POXHAHYEZTLYNFSLABODMRNKDSKROZ... |