CSES - Datatähti 2018 alku - Results
Submission details
Task:Merkkijono
Sender:mika
Submission time:2017-10-02 00:45:34 +0300
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#1ACCEPTED0.04 sdetails
#2ACCEPTED0.04 sdetails
#30.04 sdetails
#40.05 sdetails
#50.05 sdetails
#6ACCEPTED0.04 sdetails
#7ACCEPTED0.05 sdetails
#8ACCEPTED0.04 sdetails
#90.05 sdetails
#10ACCEPTED0.04 sdetails

Compiler report

input/code.cpp: In function 'std::string uus(std::string)':
input/code.cpp:31:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 1; i < s.length(); i++) {
                               ^
input/code.cpp:36:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for (int k = i; k < s.length(); k++) {
                                 ^
input/code.cpp:42:23: warning: 'loppu' may be used uninitialized in this function [-Wmaybe-uninitialized]
    s.erase(alku, loppu-alku+1);
                       ^

Code

#include <iostream>
#include <string>

using namespace std;

string uus(string in);
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;
			
			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;
}

/*string uus(string in) {
	string ss = in;
	char r;
	int a;
	int b;

	for (int i = 1; i < ss.length(); i++) {
		if (ss[i] == ss[i - 1]) {
			r = ss[i];
			
			a = i - 1;

			for (int k = i; k < ss.length(); k++) {
				if (ss[k] != r)
					b = k - 1;
			}
			cout << "remove char: " << r << endl;
			cout << "a: " << a << " b: " << b << endl;
			ss.erase(a, b);
		}
	}
	return ss;
}*/

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:

input
ABABABABABABABABABABABABABABAB...

correct output
(empty)

user output
A

Test 4

Verdict:

input
BBABABBBBBAABBBABABABBBBAAABAB...

correct output
BAB

user output
AB

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...