Task: | Merkkijono |
Sender: | ISIMO66 |
Submission time: | 2017-10-03 20:51:43 +0300 |
Language: | C++ |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | RUNTIME ERROR | 0 |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.05 s | details |
#2 | ACCEPTED | 0.04 s | details |
#3 | RUNTIME ERROR | 0.20 s | details |
#4 | WRONG ANSWER | 0.05 s | details |
#5 | RUNTIME ERROR | 0.19 s | details |
#6 | RUNTIME ERROR | 0.19 s | details |
#7 | RUNTIME ERROR | 0.23 s | details |
#8 | RUNTIME ERROR | 0.18 s | details |
#9 | RUNTIME ERROR | 0.21 s | details |
#10 | RUNTIME ERROR | 0.19 s | details |
Code
#include "stdio.h" #include "stdlib.h" int parse( char *, char **); int putChar( char, 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(); } //Parse String while(parse(str, &str)) continue; //Print String char * p = str; while (*p){ putchar(*p++); } putchar('\n'); free(str); return 0; } int parse( char * instr, char ** pointer){ char * p = instr; int i = 0; int j = 0; char * outstr = (char *)malloc(0); //Prevent segmentation fault by checking if first run int first = 1; while(*p) { j++; //Check if char is the same as next or previous char //Prevent segmentation fault by checking if first run if (!first){ if (*p == *(p-1)) { p++; continue; } } else { first = 0; } if ( *p == *(p+1) ) { p++; continue; } //Push char to array putChar( *p++, outstr, i++); } putChar( *p, outstr, i); if (instr != outstr); free(instr); *pointer = outstr; if (i == j) return 0; return 1; } int putChar( char c, char * str, int length) { str = (char *)realloc(str, (length + 1)*sizeof(char)); str[length] = c; 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: RUNTIME ERROR
input |
---|
ABABABABABABABABABABABABABABAB... |
correct output |
---|
(empty) |
user output |
---|
(empty) |
Error:
*** Error in `input/code': double free or corruption (!prev): 0x000000000098f010 ***
Test 4
Verdict: WRONG ANSWER
input |
---|
BBABABBBBBAABBBABABABBBBAAABAB... |
correct output |
---|
BAB |
user output |
---|
ABA |
Test 5
Verdict: RUNTIME ERROR
input |
---|
ACDCBBACDBBBACAACBBDBADBAABABA... |
correct output |
---|
ACDCACDADBADABACACDCADADABABCA... |
user output |
---|
(empty) |
Error:
*** Error in `input/code': double free or corruption (!prev): 0x000000000164e010 ***
Test 6
Verdict: RUNTIME ERROR
input |
---|
EETFHIJOGACDHMGVFJCMETMZDEITTR... |
correct output |
---|
TFHIJOGACDHMGVFJCMETMZDEIROTET... |
user output |
---|
(empty) |
Error:
*** Error in `input/code': double free or corruption (!prev): 0x0000000001ebd010 ***
Test 7
Verdict: RUNTIME ERROR
input |
---|
GOONLAHLYPRFCZKIKSJWAWWYJJPCDB... |
correct output |
---|
GNLAHLYPRFCZKIKSJWAYPCDNWYMRCE... |
user output |
---|
(empty) |
Error:
*** Error in `input/code': double free or corruption (!prev): 0x0000000001dd3010 ***
Test 8
Verdict: RUNTIME ERROR
input |
---|
PISHWMOTCDDZFRMYMOMYDYYGJZIQHS... |
correct output |
---|
PISHWMOTCZFRMYMOMYDGJZIQHSVAOK... |
user output |
---|
(empty) |
Error:
*** Error in `input/code': double free or corruption (!prev): 0x0000000000d86010 ***
Test 9
Verdict: RUNTIME ERROR
input |
---|
QUVVTPXAMWWODFXRONJODPGBTCISGM... |
correct output |
---|
QUTPXAMODFXRONJODPGBTCISGMVRBW... |
user output |
---|
(empty) |
Error:
*** Error in `input/code': double free or corruption (!prev): 0x0000000001067010 ***
Test 10
Verdict: RUNTIME ERROR
input |
---|
POXHAHYEZTLYNFSLABODMRNKDSKROZ... |
correct output |
---|
POXHAHYEZTLYNFSLABODMRNKDSKROZ... |
user output |
---|
(empty) |
Error:
*** Error in `input/code': double free or corruption (!prev): 0x000000000185b010 ***