Task: | Merkkijono |
Sender: | mika |
Submission time: | 2017-10-02 00:45:34 +0300 |
Language: | C++ |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.04 s | details |
#2 | ACCEPTED | 0.04 s | details |
#3 | WRONG ANSWER | 0.04 s | details |
#4 | WRONG ANSWER | 0.05 s | details |
#5 | WRONG ANSWER | 0.05 s | details |
#6 | ACCEPTED | 0.04 s | details |
#7 | ACCEPTED | 0.05 s | details |
#8 | ACCEPTED | 0.04 s | details |
#9 | WRONG ANSWER | 0.05 s | details |
#10 | ACCEPTED | 0.04 s | details |
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: WRONG ANSWER
input |
---|
ABABABABABABABABABABABABABABAB... |
correct output |
---|
(empty) |
user output |
---|
A |
Test 4
Verdict: WRONG ANSWER
input |
---|
BBABABBBBBAABBBABABABBBBAAABAB... |
correct output |
---|
BAB |
user output |
---|
AB |
Test 5
Verdict: WRONG ANSWER
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: WRONG ANSWER
input |
---|
QUVVTPXAMWWODFXRONJODPGBTCISGM... |
correct output |
---|
QUTPXAMODFXRONJODPGBTCISGMVRBW... |
user output |
---|
QUTPXAMODFXRONJODPGBTCISGMVRBW... |
Test 10
Verdict: ACCEPTED
input |
---|
POXHAHYEZTLYNFSLABODMRNKDSKROZ... |
correct output |
---|
POXHAHYEZTLYNFSLABODMRNKDSKROZ... |
user output |
---|
POXHAHYEZTLYNFSLABODMRNKDSKROZ... |