QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#477234 | #5543. The Only Mode | yzkkai | AC ✓ | 1624ms | 94160kb | C++20 | 2.2kb | 2024-07-14 00:29:16 | 2024-07-14 00:29:16 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define lowbit(x) ((x) & -(x))
inline void solve() {
int n;
cin >> n;
vector<int> a(n);
for (int& i : a)
cin >> i;
vector<vector<int>> pref(n + 1, vector<int>(4));
for (int i = 1; i <= n; ++i) {
for (int j = 0;j < 4; ++j)
pref[i][j] = pref[i - 1][j];
++pref[i][a[i - 1]];
}
auto modify = [&](int x, int y, int val, unordered_map<int, unordered_map<int, int>> &bit) -> void {
for (; x <= 2 * n + 1; x += lowbit(x))
for (int j = y; j <= 2 * n + 1; j += lowbit(j)) {
if (bit[x].count(j) == 0)
bit[x][j] = 1e9;
bit[x][j] = min(bit[x][j], val);
}
return;
};
auto query = [&](int x, int y, unordered_map<int, unordered_map<int, int>> &bit) -> int {
int ret = 1e9;
for (; x > 0; x -= lowbit(x)) {
if (bit.count(x) == 0) continue;
for (int j = y; j > 0; j -= lowbit(j))
if (bit[x].count(j))
ret = min(ret, bit[x][j]);
}
return ret;
};
vector<int> ans(4);
for (int i = 0; i < 4; ++i) {
vector<vector<int>> b(n + 1, vector<int>(4));
for (int j = 0; j <= n; ++j) {
for (int k = 0, f = 0; k < 3; ++k) {
if (k == i) ++f;
b[j][k] = pref[j][i] - pref[j][k + f] + n + 1;
}
b[j][3] = j;
}
sort(b.begin(), b.end());
unordered_map<int, unordered_map<int, int>> bit;
for (int j = 0, lst = 0; j <= n; ++j) {
if (b[lst][0] != b[j][0]) {
for (int k = lst; k < j; ++k)
modify(b[k][1], b[k][2], b[k][3], bit);
lst = j;
}
ans[i] = max(ans[i], b[j][3] - query(b[j][1] - 1, b[j][2] - 1, bit));
}
}
for (int i = 0; i < 4; ++i)
cout << ans[i] << " \n"[i == 3];
return;
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
int t = 1;
while (t--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3612kb
input:
7 1 2 2 0 3 0 3
output:
4 1 5 3
result:
ok single line: '4 1 5 3'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
12 2 0 1 0 2 1 1 0 2 3 3 3
output:
4 9 1 9
result:
ok single line: '4 9 1 9'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
2 0 2
output:
1 0 1 0
result:
ok single line: '1 0 1 0'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3788kb
input:
12 3 0 2 2 1 0 2 1 3 3 2 3
output:
1 5 11 8
result:
ok single line: '1 5 11 8'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
1 1
output:
0 1 0 0
result:
ok single line: '0 1 0 0'
Test #6:
score: 0
Accepted
time: 45ms
memory: 4164kb
input:
4207 3 1 0 3 2 0 3 1 1 1 1 3 0 1 1 0 2 2 3 0 1 1 0 1 0 2 0 1 0 0 3 3 1 0 1 3 3 0 2 0 2 0 1 0 2 3 2 3 0 0 0 0 1 2 1 2 0 2 2 0 3 3 2 2 0 2 2 0 3 0 1 3 1 1 0 2 3 0 1 2 1 2 0 0 1 1 0 3 3 2 0 2 1 3 0 1 0 3 0 0 0 2 2 2 0 1 1 0 3 1 1 3 3 2 2 1 3 3 1 3 2 0 2 3 2 2 1 0 2 3 0 1 0 0 1 1 1 3 3 1 3 3 3 0 0 0 3 2...
output:
2330 1520 4207 1359
result:
ok single line: '2330 1520 4207 1359'
Test #7:
score: 0
Accepted
time: 887ms
memory: 14652kb
input:
89925 0 0 0 3 0 3 0 2 3 2 3 1 0 0 0 2 2 1 3 3 0 0 1 0 0 3 0 1 0 0 1 1 0 0 1 2 1 3 1 2 1 2 2 1 0 2 2 3 0 0 1 0 2 3 2 3 0 0 1 0 0 1 2 1 3 0 0 0 2 1 1 0 1 3 2 2 0 0 2 3 2 3 3 1 3 3 0 2 0 2 2 0 2 1 3 0 1 1 0 0 1 0 3 1 2 2 2 0 2 0 2 3 2 0 0 2 3 3 1 0 1 2 2 2 1 2 0 0 3 2 3 0 1 1 3 3 0 0 0 3 0 2 0 0 2 3 1 ...
output:
89925 49888 75725 38162
result:
ok single line: '89925 49888 75725 38162'
Test #8:
score: 0
Accepted
time: 433ms
memory: 11380kb
input:
64937 1 1 0 2 1 1 3 1 1 1 2 0 3 1 1 2 1 2 2 1 0 2 1 1 1 1 1 0 3 1 0 2 1 0 0 0 0 2 1 2 1 2 2 1 2 3 2 1 2 1 3 0 1 3 0 0 1 3 1 2 2 2 0 3 3 1 3 0 3 3 2 0 1 1 2 0 3 3 3 2 1 0 1 0 1 3 0 0 2 1 0 3 3 1 2 3 2 1 1 0 0 3 1 1 2 1 0 2 1 0 0 1 1 3 0 1 2 1 3 2 0 3 1 2 1 2 0 0 0 1 1 2 3 3 2 1 1 1 2 1 3 1 2 2 2 0 1 ...
output:
64937 61901 51387 63870
result:
ok single line: '64937 61901 51387 63870'
Test #9:
score: 0
Accepted
time: 810ms
memory: 12584kb
input:
73423 1 2 2 0 0 0 0 2 1 2 1 2 1 3 1 3 3 0 1 2 2 0 0 0 3 2 1 1 0 3 0 2 1 3 1 1 2 3 0 1 2 1 0 0 0 3 3 0 3 2 3 3 1 1 3 2 0 0 0 3 2 0 0 2 3 3 3 3 3 2 3 2 2 2 3 3 0 1 1 2 2 2 1 2 2 1 1 2 1 2 2 3 0 3 0 2 2 2 1 2 1 1 2 3 0 1 3 2 0 3 3 3 0 2 2 2 3 1 0 1 0 1 1 3 0 0 2 1 1 3 1 3 3 2 0 2 2 1 1 0 1 0 2 3 1 2 3 ...
output:
36577 18616 60210 73423
result:
ok single line: '36577 18616 60210 73423'
Test #10:
score: 0
Accepted
time: 1286ms
memory: 13784kb
input:
82517 2 1 1 0 2 0 3 1 3 1 3 3 2 2 3 0 3 2 2 0 2 1 0 2 2 3 2 0 1 0 1 2 2 1 1 1 3 2 2 0 1 0 0 3 3 1 1 0 3 1 3 1 2 3 3 3 3 3 2 1 3 1 3 0 2 0 2 0 2 2 2 2 2 1 2 1 3 3 2 3 2 3 0 2 0 1 0 0 3 2 1 1 0 1 2 1 1 0 1 3 1 3 3 2 2 3 0 2 1 3 2 1 0 1 2 3 2 2 3 3 1 0 2 0 3 2 3 0 1 2 0 3 3 0 2 1 1 3 3 2 2 0 2 2 1 1 2 ...
output:
50863 68187 40176 82517
result:
ok single line: '50863 68187 40176 82517'
Test #11:
score: 0
Accepted
time: 917ms
memory: 13408kb
input:
79392 0 2 2 2 0 3 2 3 1 1 1 0 0 3 1 3 3 0 2 2 0 0 0 2 1 0 2 2 2 1 2 3 2 0 3 3 3 2 0 1 0 1 1 1 0 1 0 1 0 2 3 3 0 1 2 3 0 1 0 1 0 1 2 2 1 3 0 0 1 3 1 2 2 1 0 0 2 1 0 0 2 2 3 1 3 0 3 2 0 0 0 0 3 3 0 0 2 2 0 2 0 2 3 1 0 2 2 1 2 2 0 3 3 3 2 1 3 1 1 1 1 2 0 0 1 1 1 0 1 1 1 3 3 0 2 3 1 1 0 1 2 3 1 3 3 0 0 ...
output:
68113 34911 26794 79392
result:
ok single line: '68113 34911 26794 79392'
Test #12:
score: 0
Accepted
time: 1300ms
memory: 42368kb
input:
100000 2 0 0 1 0 2 3 3 0 2 1 2 0 2 0 3 0 0 2 0 1 1 0 1 1 1 1 0 2 2 0 1 0 1 0 0 0 3 1 0 3 0 1 1 1 3 1 0 1 3 1 1 1 0 1 3 0 1 1 0 1 3 0 0 0 0 0 0 0 1 0 0 1 3 1 3 0 1 0 0 2 1 1 2 2 0 3 3 2 1 1 0 0 1 1 2 0 1 2 0 3 3 1 1 1 0 3 3 0 1 3 0 1 0 2 1 3 3 2 3 2 0 2 3 0 2 2 2 0 1 0 0 1 0 2 1 1 1 2 1 2 1 1 0 3 1 1...
output:
448 100000 52 33
result:
ok single line: '448 100000 52 33'
Test #13:
score: 0
Accepted
time: 1292ms
memory: 86108kb
input:
100000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 3 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 0 0 3 0 0 0 0 0 3 0 0 0 0 0...
output:
100000 0 0 11
result:
ok single line: '100000 0 0 11'
Test #14:
score: 0
Accepted
time: 520ms
memory: 94160kb
input:
100000 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2...
output:
0 0 100000 0
result:
ok single line: '0 0 100000 0'
Test #15:
score: 0
Accepted
time: 664ms
memory: 88564kb
input:
100000 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2...
output:
0 0 33423 100000
result:
ok single line: '0 0 33423 100000'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
2 2 0
output:
1 0 1 0
result:
ok single line: '1 0 1 0'
Test #17:
score: 0
Accepted
time: 1435ms
memory: 54096kb
input:
100000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
59937 100000 30184 50197
result:
ok single line: '59937 100000 30184 50197'
Test #18:
score: 0
Accepted
time: 1624ms
memory: 94064kb
input:
100000 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2...
output:
1 3 100000 1
result:
ok single line: '1 3 100000 1'
Test #19:
score: 0
Accepted
time: 1278ms
memory: 15652kb
input:
100000 2 2 0 3 1 3 1 1 1 2 2 3 1 0 1 3 1 3 3 2 2 2 0 3 2 0 2 0 1 2 0 0 1 0 3 0 1 2 0 3 0 2 2 3 1 3 0 0 0 0 0 2 1 0 2 3 2 2 3 1 0 2 0 0 2 1 3 2 3 2 2 2 3 0 2 2 2 1 1 2 1 3 1 1 0 2 3 0 1 2 2 3 2 0 2 2 1 2 0 2 3 0 3 2 1 1 0 2 3 3 1 0 0 2 3 0 0 3 2 0 1 0 2 1 2 2 3 1 2 0 1 0 1 0 3 3 2 2 2 1 3 2 0 2 1 0 2...
output:
99993 99996 99997 99997
result:
ok single line: '99993 99996 99997 99997'
Test #20:
score: 0
Accepted
time: 1235ms
memory: 43816kb
input:
100000 2 1 0 1 1 1 3 2 1 0 2 1 1 1 1 1 3 0 3 1 1 1 1 1 1 2 3 1 0 2 1 1 2 3 1 0 1 3 1 1 3 1 3 3 2 1 2 1 1 1 1 1 1 1 1 1 1 1 2 3 1 0 3 1 1 3 1 1 1 2 3 2 3 1 1 3 0 3 0 1 2 2 3 1 3 1 0 2 3 1 1 1 3 1 1 0 1 2 1 0 0 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 1 0 3 3 2 0 3 1 1 0 1 2 3 3 1 1 1 1 1 3 1 1 1 3 0 2 1...
output:
69 100000 42 181
result:
ok single line: '69 100000 42 181'
Test #21:
score: 0
Accepted
time: 1466ms
memory: 32332kb
input:
100000 2 2 0 2 1 2 2 0 0 0 3 0 2 1 0 2 0 0 3 0 0 1 1 0 2 1 3 0 0 1 1 2 1 2 0 2 2 2 1 2 2 2 2 0 1 0 0 2 3 1 2 2 0 1 3 2 1 1 0 0 0 1 1 1 2 1 2 0 0 2 3 2 1 2 1 1 2 2 1 3 2 0 2 1 0 1 2 0 1 2 3 2 2 0 3 2 3 1 2 0 1 2 2 0 2 1 1 1 2 0 2 1 2 2 0 3 1 3 2 0 1 1 2 0 2 0 2 2 2 0 0 1 1 1 2 3 2 1 1 3 1 1 2 1 1 3 3...
output:
99998 99997 99265 50
result:
ok single line: '99998 99997 99265 50'
Test #22:
score: 0
Accepted
time: 1316ms
memory: 16000kb
input:
100000 1 1 3 0 0 3 1 0 1 0 1 2 2 3 0 3 3 2 1 1 0 2 0 1 2 0 3 0 2 3 1 1 3 1 3 2 1 0 0 1 3 0 0 3 3 3 3 3 1 0 1 1 1 0 1 2 1 1 0 1 1 0 1 3 3 0 2 1 3 1 1 2 2 2 2 1 0 1 1 1 3 2 3 1 1 3 0 3 0 3 2 3 2 3 0 0 1 3 3 2 0 1 1 1 3 2 0 1 3 0 1 2 2 2 1 3 1 1 1 1 1 0 2 3 3 2 3 3 3 2 2 3 1 2 0 1 1 3 1 1 3 3 2 2 1 2 1...
output:
99902 99960 99996 99996
result:
ok single line: '99902 99960 99996 99996'
Test #23:
score: 0
Accepted
time: 736ms
memory: 14424kb
input:
100000 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2...
output:
99997 99997 99997 99997
result:
ok single line: '99997 99997 99997 99997'
Test #24:
score: 0
Accepted
time: 1204ms
memory: 56472kb
input:
100000 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3...
output:
49999 74998 74998 49999
result:
ok single line: '49999 74998 74998 49999'
Test #25:
score: 0
Accepted
time: 1540ms
memory: 54944kb
input:
100000 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3...
output:
99038 98842 99667 74993
result:
ok single line: '99038 98842 99667 74993'
Test #26:
score: 0
Accepted
time: 1007ms
memory: 28604kb
input:
100000 1 2 0 2 3 0 1 2 0 2 3 0 1 2 0 2 3 0 1 2 0 2 3 0 1 2 0 2 3 0 1 2 0 2 3 0 1 2 0 2 3 0 1 2 0 2 3 0 1 2 0 2 3 0 1 2 0 2 3 0 1 2 0 2 3 0 1 2 0 2 3 0 1 2 0 2 3 0 1 2 0 2 3 0 1 2 0 2 3 0 1 2 0 2 3 0 1 2 0 2 3 0 1 2 0 2 3 0 1 2 0 2 3 0 1 2 0 2 3 0 1 2 0 2 3 0 1 2 0 2 3 0 1 2 0 2 3 0 1 2 0 2 3 0 1 2 0...
output:
99997 1 100000 1
result:
ok single line: '99997 1 100000 1'
Test #27:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
3 3 1 3
output:
0 1 0 3
result:
ok single line: '0 1 0 3'
Test #28:
score: 0
Accepted
time: 1194ms
memory: 29112kb
input:
100000 2 2 0 0 3 3 0 2 1 2 1 0 2 2 0 0 3 3 0 2 1 2 1 0 2 2 0 0 3 3 0 2 1 2 1 0 2 2 0 0 3 3 0 2 1 2 1 0 2 2 0 0 3 3 0 2 1 2 1 0 2 2 0 0 3 3 0 2 1 2 1 0 2 2 0 0 3 3 0 2 1 2 1 0 2 2 0 0 3 3 0 2 1 2 1 0 2 2 0 0 3 3 0 2 1 2 1 0 2 2 0 0 3 3 0 2 1 2 1 0 2 2 0 0 3 3 0 2 1 2 1 0 2 2 0 0 3 3 0 2 1 2 1 0 2 2 0...
output:
99999 4 99999 5
result:
ok single line: '99999 4 99999 5'
Test #29:
score: 0
Accepted
time: 1297ms
memory: 16196kb
input:
100000 2 2 2 0 0 2 2 3 2 0 1 1 1 2 2 3 2 2 2 2 2 0 1 2 1 1 3 3 3 0 2 1 2 1 0 3 0 3 3 2 3 0 3 3 0 3 3 3 1 2 1 1 2 1 2 2 0 2 1 2 3 1 2 2 2 1 1 3 3 3 2 2 0 1 1 0 0 3 2 2 1 1 1 3 2 2 3 1 2 1 0 2 0 2 2 3 3 2 1 0 2 3 0 0 1 0 0 3 0 1 2 2 1 0 0 0 3 1 1 1 1 0 0 2 2 2 1 1 2 3 2 3 0 0 3 2 0 3 0 1 0 3 0 0 0 1 0...
output:
31701 90659 88119 100000
result:
ok single line: '31701 90659 88119 100000'
Test #30:
score: 0
Accepted
time: 1334ms
memory: 16180kb
input:
100000 0 1 3 2 2 0 1 0 2 0 1 2 1 1 1 3 0 2 1 1 3 2 3 2 0 3 2 2 2 3 3 1 0 0 1 3 0 2 3 1 0 0 1 1 3 0 2 0 2 2 2 0 2 1 1 0 2 3 0 3 0 2 0 2 3 0 2 1 2 3 1 0 2 1 0 1 2 2 3 1 3 1 0 1 1 2 0 1 2 2 0 1 1 3 3 0 0 1 3 1 1 0 0 3 2 0 1 0 1 1 3 2 1 3 2 3 1 3 2 2 2 3 1 0 3 0 1 0 3 2 0 3 2 1 3 3 2 3 1 0 1 1 3 3 0 1 3...
output:
62661 100000 86884 68086
result:
ok single line: '62661 100000 86884 68086'
Test #31:
score: 0
Accepted
time: 1298ms
memory: 16072kb
input:
100000 2 0 3 2 2 1 1 0 0 3 1 2 1 3 1 3 3 0 0 3 2 2 0 0 3 0 1 3 3 2 1 3 1 1 0 1 1 2 2 1 0 3 2 2 2 0 1 3 2 0 1 2 2 3 2 0 1 3 2 3 0 2 0 2 3 3 2 2 2 1 3 0 1 0 3 0 1 2 2 2 1 1 0 0 0 3 1 2 2 0 3 0 2 1 2 2 1 0 0 0 2 0 1 3 1 0 0 2 0 0 3 2 2 2 1 3 3 3 2 2 0 0 3 1 1 2 0 3 3 1 2 1 1 0 0 3 1 2 0 1 2 0 0 0 3 2 3...
output:
77511 28943 63391 100000
result:
ok single line: '77511 28943 63391 100000'
Test #32:
score: 0
Accepted
time: 1338ms
memory: 15896kb
input:
100000 1 2 3 1 0 2 0 0 0 3 3 0 2 1 2 0 0 3 2 2 3 0 1 3 3 3 1 2 0 2 3 0 2 1 1 2 0 0 3 3 2 1 1 3 2 0 0 3 0 0 0 3 3 1 1 1 1 0 0 3 1 2 1 1 0 2 3 3 0 2 0 0 2 3 0 0 0 3 2 2 2 1 1 3 2 0 3 3 3 0 0 1 0 1 1 0 2 3 2 0 1 2 2 0 1 3 1 2 3 1 3 1 1 2 0 1 3 1 0 1 2 3 2 3 0 1 3 3 1 1 2 2 3 0 2 0 0 1 3 3 2 3 0 3 2 2 3...
output:
81571 73712 100000 99871
result:
ok single line: '81571 73712 100000 99871'
Test #33:
score: 0
Accepted
time: 1309ms
memory: 16012kb
input:
100000 3 0 1 0 1 0 3 1 2 0 2 3 2 3 1 0 1 0 3 0 1 0 0 1 0 0 1 1 0 2 1 2 3 0 1 2 2 1 0 2 1 1 0 1 3 1 3 0 0 1 2 1 2 3 3 3 0 3 0 0 3 0 1 0 3 1 1 1 1 1 1 3 3 3 3 0 0 0 1 1 0 1 1 3 3 2 0 1 1 1 3 0 0 3 3 3 2 3 3 2 2 1 0 3 1 3 3 1 2 2 3 3 0 3 1 2 0 1 3 3 3 1 1 2 3 2 0 1 2 2 0 2 0 1 1 2 3 1 3 2 2 0 2 0 3 3 2...
output:
27558 100000 48059 95964
result:
ok single line: '27558 100000 48059 95964'
Test #34:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
4 2 1 3 0
output:
1 1 1 1
result:
ok single line: '1 1 1 1'
Test #35:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
10 1 0 1 2 3 0 2 0 1 3
output:
9 5 5 1
result:
ok single line: '9 5 5 1'
Test #36:
score: 0
Accepted
time: 18ms
memory: 3956kb
input:
2970 2 2 3 2 3 2 3 1 2 2 1 1 1 3 0 3 1 1 1 3 3 2 1 2 1 3 3 0 1 0 2 0 1 3 3 3 0 3 3 3 1 3 3 1 2 3 2 0 2 2 2 0 2 3 3 2 0 1 1 1 0 3 2 1 0 2 0 0 1 2 0 2 0 2 1 3 3 2 1 1 2 1 3 2 0 0 3 2 2 2 0 0 1 0 3 1 2 1 1 2 0 1 2 3 3 0 2 0 2 0 3 2 2 1 1 1 1 0 2 0 1 0 2 2 1 0 3 0 3 1 2 3 0 0 2 3 2 0 3 3 3 1 2 3 0 2 1 2...
output:
2590 2970 2754 2815
result:
ok single line: '2590 2970 2754 2815'
Test #37:
score: 0
Accepted
time: 22ms
memory: 4032kb
input:
3362 2 1 3 3 1 0 1 2 1 3 2 3 1 1 3 2 3 1 0 3 0 0 0 3 0 0 0 2 1 1 3 0 0 1 1 3 3 0 2 0 3 3 2 3 3 1 2 3 0 2 0 2 1 3 2 0 3 0 1 1 2 1 3 0 1 3 3 2 2 3 3 0 2 2 2 0 3 1 3 3 0 3 2 3 1 3 3 1 0 0 3 3 3 2 0 3 1 3 2 3 2 1 3 3 3 1 1 0 1 2 2 2 0 1 0 0 1 1 1 1 3 3 2 0 1 2 3 0 3 2 3 1 3 3 1 1 0 0 3 3 0 3 1 2 3 0 3 0...
output:
1302 2637 1953 3362
result:
ok single line: '1302 2637 1953 3362'
Test #38:
score: 0
Accepted
time: 38ms
memory: 4180kb
input:
4523 1 1 2 2 3 3 3 1 1 2 1 0 0 1 3 0 2 1 1 1 1 1 0 0 1 0 1 1 0 0 2 2 3 2 1 2 1 0 3 2 2 0 2 0 1 1 1 0 2 2 3 3 3 2 2 3 1 3 3 2 0 2 1 2 1 3 1 1 2 3 0 2 3 1 2 0 1 0 0 2 2 2 1 1 2 1 3 2 0 0 0 1 0 1 2 2 0 2 1 1 0 3 2 0 0 0 0 1 2 3 3 1 2 0 0 3 3 0 0 1 0 2 1 1 2 0 1 1 2 3 2 3 3 0 3 0 2 3 0 2 1 2 2 3 1 0 3 0...
output:
4523 4511 3922 4475
result:
ok single line: '4523 4511 3922 4475'
Test #39:
score: 0
Accepted
time: 18ms
memory: 3908kb
input:
2403 3 1 0 0 2 3 3 3 2 2 1 0 2 3 3 1 3 0 3 2 2 2 2 2 3 1 2 3 0 1 1 2 1 3 1 2 1 0 0 3 2 3 0 3 0 1 1 3 3 0 3 1 0 3 1 0 3 1 0 3 0 1 0 0 1 1 3 2 3 1 3 3 1 3 1 0 0 0 2 1 0 1 1 0 3 0 0 3 0 2 1 2 3 2 3 0 3 0 0 2 1 2 1 3 2 2 1 2 3 1 3 3 3 3 1 1 1 1 2 0 3 3 1 2 0 1 2 2 0 3 1 3 2 0 3 3 0 2 3 0 0 1 0 2 1 3 2 0...
output:
1437 2403 2320 1954
result:
ok single line: '1437 2403 2320 1954'