QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#448158 | #8689. Compression | james1BadCreeper# | WA | 1ms | 3820kb | C++17 | 551b | 2024-06-19 12:53:21 | 2024-06-19 12:53:22 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, m;
char a[N], b[N];
int main(void) {
cin >> a + 1; n = strlen(a + 1);
for (int i = 1; i <= n; ++i)
if (m && b[m] == a[i]) continue;
else b[++m] = a[i];
vector<int> del(m + 5);
for (int i = 3; i <= m; ++i)
if (i + 1 <= m && b[i] == b[i - 2] && b[i + 1] == b[i - 1])
del[i] = del[i + 1] = 1;
for (int i = 1; i <= m; ++i)
if (!del[i]) cout << b[i];
cout << "\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3648kb
input:
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
0
result:
ok single line: '0'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3700kb
input:
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...
output:
1
result:
ok single line: '1'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
0
output:
0
result:
ok single line: '0'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
1
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 1ms
memory: 3812kb
input:
111110000011111000001111100000111110000011111000001111100000111110000011111000001111100000111110000011111000001111100000111110000011111000001111100000111110000011111000001111100000111110000011111000001111100000111110000011111000001111100000111110000011111000001111100000111110000011111000001111100000...
output:
10
result:
ok single line: '10'
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 3820kb
input:
010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101...
output:
01
result:
wrong answer 1st lines differ - expected: '010', found: '01'