CSES - Datatähti 2018 alku - Results
Submission details
Task:Merkkijono
Sender:1
Submission time:2017-10-05 20:49:56 +0300
Language:C++
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED100
Test results
testverdicttime
#1ACCEPTED0.06 sdetails
#2ACCEPTED0.05 sdetails
#3ACCEPTED0.05 sdetails
#4ACCEPTED0.04 sdetails
#5ACCEPTED0.06 sdetails
#6ACCEPTED0.06 sdetails
#7ACCEPTED0.04 sdetails
#8ACCEPTED0.06 sdetails
#9ACCEPTED0.04 sdetails
#10ACCEPTED0.06 sdetails

Compiler report

input/code.cpp: In function 'int firstDouble(std::string)':
input/code.cpp:8:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < s.length() - 1; i++) {
                                      ^
input/code.cpp: In function 'std::string removeChars(std::string, int)':
input/code.cpp:17:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while (loc + l < s.length() && s[loc + l] == s[loc]) {
                               ^

Code

#include <iostream>
#include <string>

using namespace std;

int firstDouble(string s) {
    if (s.length() < 2) return -1;
    for (int i = 0; i < s.length() - 1; i++) {
        if (s[i] == s[i+1]) return i;
    }
    return -1;
}

string removeChars(string s, int loc) {
    string ns = s.substr(0, loc);
    int l = 0;
    while (loc + l < s.length() && s[loc + l] == s[loc]) {
        ++l;
    }
    return ns + s.substr(loc + l, s.length() - loc - l);
}

int main(int argc, const char * argv[]) {
    string s;
    cin >> s;
    int dloc = firstDouble(s);
    while (dloc > -1) {
        s = removeChars(s, dloc);
        dloc = firstDouble(s);
    }
    cout << s << endl;
    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...