CSES - Datatähti 2018 alku - Results
Submission details
Task:Merkkijono
Sender:juhajgamer
Submission time:2017-10-13 22:15:41 +0300
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#10.07 sdetails
#20.06 sdetails
#30.08 sdetails
#4--details
#5--details
#60.05 sdetails
#70.05 sdetails
#80.06 sdetails
#90.06 sdetails
#100.05 sdetails

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:12:38: warning: non-constant array size in new, unable to verify length of initializer-list [enabled by default]
     char* str = new char[len+1] {'\0'};
                                      ^
input/code.cpp:17:42: warning: non-constant array size in new, unable to verify length of initializer-list [enabled by default]
         char *str2 = new char[len+1]{'\0'};
                                          ^
input/code.cpp:20:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i = 0; i<len;i++)
                          ^

Code

#include <iostream>
#include <cstring>
#define MAX_LENGTH 10000000
using namespace std;

int main()
{
    char* sin = new char[MAX_LENGTH];
    cout << ">";
    cin >> sin;
    size_t len = strlen(sin);
    char* str = new char[len+1] {'\0'};
    strcpy(str,sin);
    delete [] sin;
    while(true)
    {
        char *str2 = new char[len+1]{'\0'};
        int f = 0;
        int strc = 0;
        for(int i = 0; i<len;i++)
        {
            if(f==0) 
            {
                if(str[i] == str[i+1])
                {   
                    f++;
                }
                else
                {
                    str2[strc] = str[i];
                    strc++;
                }
            }
            else if (f==1)
            {
                if(str[i] != str[i-1])
                {
                    str2[strc] = str[i];
                    strc++;
                    f++;
                }
            }
            else
            {
                str2[strc] = str[i];
                strc++;
            }
        }
        strcpy(str,str2); 
        if(f == 0) break;
    }
    cout << str << "\n\0";
}

Test details

Test 1

Verdict:

input
ABABABABABABABABABABABABABABAB...

correct output
ABABABABABABABABABABABABABABAB...

user output
>ABABABABABABABABABABABABABABA...

Test 2

Verdict:

input
AABBAABBAABBAABBAABBAABBAABBAA...

correct output
(empty)

user output
>

Test 3

Verdict:

input
ABABABABABABABABABABABABABABAB...

correct output
(empty)

user output
>

Test 4

Verdict:

input
BBABABBBBBAABBBABABABBBBAAABAB...

correct output
BAB

user output
(empty)

Test 5

Verdict:

input
ACDCBBACDBBBACAACBBDBADBAABABA...

correct output
ACDCACDADBADABACACDCADADABABCA...

user output
(empty)

Test 6

Verdict:

input
EETFHIJOGACDHMGVFJCMETMZDEITTR...

correct output
TFHIJOGACDHMGVFJCMETMZDEIROTET...

user output
>TFHIJOGACDHMGVFJCMETMZDEIROTE...

Test 7

Verdict:

input
GOONLAHLYPRFCZKIKSJWAWWYJJPCDB...

correct output
GNLAHLYPRFCZKIKSJWAYPCDNWYMRCE...

user output
>GNLAHLYPRFCZKIKSJWAYPCDNWYMRC...

Test 8

Verdict:

input
PISHWMOTCDDZFRMYMOMYDYYGJZIQHS...

correct output
PISHWMOTCZFRMYMOMYDGJZIQHSVAOK...

user output
>PISHWMOTCZFRMYMOMYDGJZIQHSVAO...

Test 9

Verdict:

input
QUVVTPXAMWWODFXRONJODPGBTCISGM...

correct output
QUTPXAMODFXRONJODPGBTCISGMVRBW...

user output
>QUTPXAMODFXRONJODPGBTCISGMVRB...

Test 10

Verdict:

input
POXHAHYEZTLYNFSLABODMRNKDSKROZ...

correct output
POXHAHYEZTLYNFSLABODMRNKDSKROZ...

user output
>POXHAHYEZTLYNFSLABODMRNKDSKRO...