CSES - Datatähti 2018 alku - Results
Submission details
Task:Merkkijono
Sender:mika
Submission time:2017-10-02 02:09:22 +0300
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#1ACCEPTED0.03 sdetails
#2ACCEPTED0.04 sdetails
#3ACCEPTED0.04 sdetails
#40.04 sdetails
#50.04 sdetails
#6ACCEPTED0.04 sdetails
#7ACCEPTED0.05 sdetails
#8ACCEPTED0.05 sdetails
#90.04 sdetails
#10ACCEPTED0.05 sdetails

Compiler report

input/code.cpp: In function 'std::string uus(std::string)':
input/code.cpp:37:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 1; i < s.length(); i++) {
                               ^
input/code.cpp:42:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for (int k = i; k < s.length(); k++) {
                                 ^

Code

#include <iostream>
#include <string>

using namespace std;

string uus(string in);

// CAACCB
// ABBCDDDCCBE
// B
// AAAAAAAAAAA

int main() {
	string in;
	cin >> in;

	in = uus(in);

	while (true) {
		string ss = uus(in);
		if (in == ss) {
			break;
		}
		else {
			in = ss;
		}
	}

	cout << in << endl;

	return 0;
}

string uus(string in) {
	string s = in;

	for (int i = 1; i < s.length(); i++) {
		if (s[i] == s[i - 1]) {
			int alku = i - 1;
			int loppu = s.length() -1;

			for (int k = i; k < s.length(); k++) {
				if (s[k] != s[k - 1]) {
					loppu = k - 1;
					break;
				}
			}
			s.erase(alku, loppu - alku + 1);
		}
	}
	return s;
}

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:

input
BBABABBBBBAABBBABABABBBBAAABAB...

correct output
BAB

user output
A

Test 5

Verdict:

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:

input
QUVVTPXAMWWODFXRONJODPGBTCISGM...

correct output
QUTPXAMODFXRONJODPGBTCISGMVRBW...

user output
QUTPXAMODFXRONJODPGBTCISGMVRBW...

Test 10

Verdict: ACCEPTED

input
POXHAHYEZTLYNFSLABODMRNKDSKROZ...

correct output
POXHAHYEZTLYNFSLABODMRNKDSKROZ...

user output
POXHAHYEZTLYNFSLABODMRNKDSKROZ...