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

Code

// g++ -std=c++0x -O2 -Wall merkkijono.cc -o merkkijono
#include <iostream>
#include <list>
#include <string>

int main()
{
	std::list<char> lista;
	std::string merkkijono;
	
	std::getline(std::cin, merkkijono);
	
	for (auto i = merkkijono.begin(); i != merkkijono.end(); ++i) {
		lista.push_back(*i);
	}
		
	for (auto i1 = lista.begin(); i1 != lista.end();) {
		auto i2 = i1;		
		// Kaikki identtiset kirjaimet ovat välillä [i1, i2].
		while (i2 != lista.end() && *i1 == *i2) {
			++i2;
		}
		--i2;
		// Jos kirjaimia on yli 1, niin poistetaan ne. Jos ei, niin edetään yksi kirjan eteenpäin.
		if (i1 != i2) {
			++i2;
			i1 = lista.erase(i1, i2);
			if (i1 != lista.begin()) {
				--i1;
			}
		} else {
			++i1;
		}
	}
	
	for (auto i = lista.begin(); i != lista.end(); ++i) {
		std::cout << *i;
	}
	std::cout << std::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...