QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#143067 | #4565. Rarest Insects | bashkort# | 10 | 5ms | 4156kb | C++17 | 5.1kb | 2023-08-20 15:04:23 | 2024-07-04 01:50:18 |
Judging History
answer
#include "insects.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
mt19937 rnd(228);
int min_cardinality(int N) {
vector<int> a(N);
iota(a.begin(), a.end(), 0);
shuffle(a.begin(), a.end(), rnd);
vector<int> leaders, inside(N);
int maxSize = 0, T = 0, lastQueryT = 0;
int queriesCnt[3]{};
auto insert = [&](int x) -> void {
if (inside[x]) {
return;
}
move_inside(x);
T += 1;
queriesCnt[0] += 1;
inside[x] = true;
};
auto erase = [&](int x) -> void {
if (!inside[x]) {
return;
}
move_outside(x);
T += 1;
queriesCnt[1] += 1;
inside[x] = false;
};
auto query = [&]() -> int {
if (T == lastQueryT) {
return maxSize;
}
lastQueryT = T;
queriesCnt[2] += 1;
return maxSize = press_button();
};
vector<int> others, lo(N, -1), hi(N, -1);
for (int x : a) {
insert(x);
if (query() == 1) {
leaders.push_back(x);
} else {
others.push_back(x);
lo[x] = -1, hi[x] = size(leaders) - 1;
erase(x);
}
};
int ans = N;
int minPos = 0, maxPos = size(leaders), full = true;
int m = size(leaders);
vector<vector<int>> queries(m);
vector<int> siz(m);
while (true) {
for (int i = 0; i < m; ++i) {
queries[i].clear();
}
minPos = N, maxPos = 0;
for (int i = 0; i < N; ++i) {
if (lo[i] + 1 < hi[i]) {
int mid = lo[i] + hi[i] >> 1;
minPos = min(minPos, mid), maxPos = max(maxPos, mid);
queries[lo[i] + hi[i] >> 1].push_back(i);
}
}
if (minPos > maxPos) {
break;
}
full = rnd() % 2;
if (full) {
for (int i = m - 1; i > maxPos; --i) {
erase(leaders[i]);
}
for (int i = 0; i <= maxPos; ++i) {
insert(leaders[i]);
}
for (int i = maxPos; i >= minPos; --i) {
for (int x : queries[i]) {
insert(x);
if (query() == 2) {
hi[x] = i;
if (lo[x] + 1 < hi[x]) {
int mid = lo[x] + hi[x] >> 1;
if (mid >= minPos) {
queries[mid].push_back(x);
}
}
} else {
lo[x] = i;
}
erase(x);
}
if (i > minPos) {
erase(leaders[i]);
}
}
full = false;
} else {
for (int i = m - 1; i > minPos; --i) {
erase(leaders[i]);
}
for (int i = 0; i < minPos; ++i) {
insert(leaders[i]);
}
for (int i = minPos; i <= maxPos; ++i) {
insert(leaders[i]);
for (int x : queries[i]) {
insert(x);
if (query() == 2) {
hi[x] = i;
} else {
lo[x] = i;
if (lo[x] + 1 < hi[x]) {
int mid = lo[x] + hi[x] >> 1;
if (mid <= maxPos) {
queries[mid].push_back(x);
}
}
}
erase(x);
}
}
full = true;
}
}
for (int i = 0; i < N; ++i) {
if (hi[i] != -1) {
siz[hi[i]] += 1;
}
}
for (int i = 0; i < m; ++i) {
ans = min(ans, 1 + siz[i]);
}
auto dfs = [&](auto dfs, vector<int> lead, vector<int> oth, int isFull) -> void {
if (ans == 1) {
return;
}
if (size(lead) == 1) {
ans = min<int>(ans, 1 + size(oth));
return;
}
if (size(lead) > size(oth)) {
ans = 1;
return;
}
int mid = size(lead) / 2;
vector<int> leadLeft(lead.begin(), lead.begin() + mid);
vector<int> leadRight(lead.begin() + mid, lead.end());
vector<int> nxt[2];
if (isFull) {
for (int x : leadRight) {
erase(x);
}
} else {
for (int x : leadLeft) {
insert(x);
}
}
for (int x : oth) {
insert(x);
if (query() == 1) {
nxt[1].push_back(x);
} else {
nxt[0].push_back(x);
}
erase(x);
}
dfs(dfs, leadLeft, nxt[0], true);
dfs(dfs, leadRight, nxt[1], false);
};
// dfs(dfs, leaders, others, true);
return ans;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 0ms
memory: 4112kb
input:
6 1 1 2 1 2 2 1 2 2 2
output:
8 0 2 8 2 8 0 0 8 2 8 0 4 8 2 8 1 4 8 0 1 8 2 8 0 5 8 2 8 1 5 8 0 3 8 2 8 1 3 8 1 1 8 1 0 8 0 3 8 2 8 1 3 8 0 4 8 2 8 1 4 8 0 5 8 2 8 1 5 8 0 0 8 0 3 8 2 8 1 3 8 3 1
result:
ok
Test #2:
score: 0
Accepted
time: 1ms
memory: 3848kb
input:
2 1 2
output:
8 0 1 8 2 8 0 0 8 2 8 1 0 8 3 2
result:
ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 3784kb
input:
2 1 1
output:
8 0 1 8 2 8 0 0 8 2 8 3 1
result:
ok
Test #4:
score: 0
Accepted
time: 1ms
memory: 3880kb
input:
3 1 1 2 2
output:
8 0 1 8 2 8 0 0 8 2 8 0 2 8 2 8 1 2 8 1 0 8 0 2 8 2 8 1 2 8 3 1
result:
ok
Test #5:
score: 0
Accepted
time: 1ms
memory: 4108kb
input:
5 1 2 1 2 2 1 2
output:
8 0 3 8 2 8 0 0 8 2 8 1 0 8 0 2 8 2 8 0 1 8 2 8 1 1 8 0 4 8 2 8 1 4 8 1 2 8 0 1 8 2 8 1 1 8 0 4 8 2 8 1 4 8 3 2
result:
ok
Test #6:
score: 0
Accepted
time: 0ms
memory: 3884kb
input:
8 1 1 1 2 2 2 2 2 2 2 2 2 1 2
output:
8 0 2 8 2 8 0 0 8 2 8 0 7 8 2 8 0 1 8 2 8 1 1 8 0 5 8 2 8 1 5 8 0 3 8 2 8 1 3 8 0 4 8 2 8 1 4 8 0 6 8 2 8 1 6 8 1 7 8 1 0 8 0 1 8 2 8 1 1 8 0 3 8 2 8 1 3 8 0 4 8 2 8 1 4 8 0 5 8 2 8 1 5 8 0 6 8 2 8 1 6 8 0 0 8 0 6 8 2 8 1 6 8 3 1
result:
ok
Test #7:
score: 0
Accepted
time: 2ms
memory: 4072kb
input:
199 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 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:
8 0 187 8 2 8 0 6 8 2 8 1 6 8 0 139 8 2 8 1 139 8 0 110 8 2 8 1 110 8 0 54 8 2 8 1 54 8 0 198 8 2 8 1 198 8 0 193 8 2 8 1 193 8 0 23 8 2 8 1 23 8 0 46 8 2 8 1 46 8 0 66 8 2 8 1 66 8 0 20 8 2 8 1 20 8 0 87 8 2 8 1 87 8 0 92 8 2 8 1 92 8 0 105 8 2 8 1 105 8 0 153 8 2 8 1 153 8 0 99 8 2 8 1 99 8 0 135 ...
result:
ok
Test #8:
score: 0
Accepted
time: 2ms
memory: 3820kb
input:
200 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
output:
8 0 186 8 2 8 0 131 8 2 8 0 138 8 2 8 0 149 8 2 8 0 45 8 2 8 0 83 8 2 8 0 192 8 2 8 0 99 8 2 8 0 25 8 2 8 0 125 8 2 8 0 10 8 2 8 0 179 8 2 8 0 20 8 2 8 0 104 8 2 8 0 152 8 2 8 0 98 8 2 8 0 183 8 2 8 0 87 8 2 8 0 113 8 2 8 0 26 8 2 8 0 126 8 2 8 0 190 8 2 8 0 90 8 2 8 0 89 8 2 8 0 47 8 2 8 0 79 8 2 8...
result:
ok
Test #9:
score: 0
Accepted
time: 0ms
memory: 4076kb
input:
200 1 1 1 1 1 2 1 1 2 1 2 2 2 2 1 2 2 1 2 2 1 1 2 1 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 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:
8 0 186 8 2 8 0 131 8 2 8 0 138 8 2 8 0 149 8 2 8 0 45 8 2 8 0 83 8 2 8 1 83 8 0 192 8 2 8 0 99 8 2 8 0 25 8 2 8 1 25 8 0 125 8 2 8 0 10 8 2 8 1 10 8 0 179 8 2 8 1 179 8 0 20 8 2 8 1 20 8 0 104 8 2 8 1 104 8 0 152 8 2 8 0 98 8 2 8 1 98 8 0 183 8 2 8 1 183 8 0 87 8 2 8 0 113 8 2 8 1 113 8 0 26 8 2 8 ...
result:
ok
Test #10:
score: 0
Accepted
time: 5ms
memory: 3820kb
input:
198 1 1 1 1 1 1 2 2 2 1 2 2 1 2 2 1 2 2 2 1 2 1 2 2 2 2 1 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 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:
8 0 186 8 2 8 0 131 8 2 8 0 138 8 2 8 0 149 8 2 8 0 45 8 2 8 0 83 8 2 8 0 192 8 2 8 1 192 8 0 99 8 2 8 1 99 8 0 25 8 2 8 1 25 8 0 125 8 2 8 0 10 8 2 8 1 10 8 0 179 8 2 8 1 179 8 0 20 8 2 8 0 104 8 2 8 1 104 8 0 152 8 2 8 1 152 8 0 98 8 2 8 0 183 8 2 8 1 183 8 0 87 8 2 8 1 87 8 0 113 8 2 8 1 113 8 0 ...
result:
ok
Test #11:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
199 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 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:
8 0 187 8 2 8 0 6 8 2 8 1 6 8 0 139 8 2 8 1 139 8 0 110 8 2 8 1 110 8 0 54 8 2 8 1 54 8 0 198 8 2 8 1 198 8 0 193 8 2 8 1 193 8 0 23 8 2 8 1 23 8 0 46 8 2 8 1 46 8 0 66 8 2 8 1 66 8 0 20 8 2 8 1 20 8 0 87 8 2 8 1 87 8 0 92 8 2 8 1 92 8 0 105 8 2 8 1 105 8 0 153 8 2 8 1 153 8 0 99 8 2 8 1 99 8 0 135 ...
result:
ok
Test #12:
score: 0
Accepted
time: 4ms
memory: 4108kb
input:
197 1 1 2 2 2 1 1 1 1 1 2 2 2 1 1 2 2 1 1 2 1 2 1 1 1 2 1 1 1 1 1 2 2 1 1 1 2 1 1 2 2 1 2 2 2 2 1 2 1 2 2 1 2 1 2 1 1 1 2 1 1 2 1 2 2 2 1 2 1 2 1 2 1 1 1 1 2 1 2 2 1 2 1 2 2 2 1 2 2 1 2 2 1 2 1 2 2 2 2 1 2 2 1 1 2 2 1 2 1 1 1 1 1 2 2 2 1 2 2 2 1 1 1 1 1 1 2 2 2 1 1 2 2 1 2 2 2 2 2 2 1 1 2 2 1 1 1 1 ...
output:
8 0 187 8 2 8 0 6 8 2 8 0 139 8 2 8 1 139 8 0 110 8 2 8 1 110 8 0 54 8 2 8 1 54 8 0 47 8 2 8 0 193 8 2 8 0 23 8 2 8 0 46 8 2 8 0 66 8 2 8 0 20 8 2 8 1 20 8 0 87 8 2 8 1 87 8 0 92 8 2 8 1 92 8 0 105 8 2 8 0 153 8 2 8 0 99 8 2 8 1 99 8 0 135 8 2 8 1 135 8 0 18 8 2 8 0 43 8 2 8 0 12 8 2 8 1 12 8 0 127 ...
result:
ok
Test #13:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
197 1 1 2 2 1 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 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:
8 0 187 8 2 8 0 6 8 2 8 0 139 8 2 8 1 139 8 0 110 8 2 8 1 110 8 0 54 8 2 8 0 47 8 2 8 1 47 8 0 193 8 2 8 1 193 8 0 23 8 2 8 0 46 8 2 8 1 46 8 0 66 8 2 8 1 66 8 0 20 8 2 8 1 20 8 0 87 8 2 8 1 87 8 0 92 8 2 8 1 92 8 0 105 8 2 8 1 105 8 0 153 8 2 8 1 153 8 0 99 8 2 8 1 99 8 0 135 8 2 8 1 135 8 0 18 8 2...
result:
ok
Test #14:
score: 0
Accepted
time: 1ms
memory: 3824kb
input:
198 1 1 1 2 1 2 1 1 1 1 1 2 2 2 2 1 2 2 2 2 2 1 2 2 2 2 2 2 2 1 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 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:
8 0 186 8 2 8 0 131 8 2 8 0 138 8 2 8 0 149 8 2 8 1 149 8 0 45 8 2 8 0 83 8 2 8 1 83 8 0 192 8 2 8 0 99 8 2 8 0 25 8 2 8 0 125 8 2 8 0 10 8 2 8 0 179 8 2 8 1 179 8 0 20 8 2 8 1 20 8 0 104 8 2 8 1 104 8 0 152 8 2 8 1 152 8 0 98 8 2 8 0 183 8 2 8 1 183 8 0 87 8 2 8 1 87 8 0 113 8 2 8 1 113 8 0 26 8 2 ...
result:
ok
Test #15:
score: 0
Accepted
time: 4ms
memory: 3824kb
input:
200 1 1 1 2 1 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 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:
8 0 186 8 2 8 0 131 8 2 8 0 138 8 2 8 0 149 8 2 8 1 149 8 0 45 8 2 8 0 83 8 2 8 1 83 8 0 192 8 2 8 1 192 8 0 99 8 2 8 1 99 8 0 25 8 2 8 1 25 8 0 125 8 2 8 1 125 8 0 10 8 2 8 0 179 8 2 8 1 179 8 0 20 8 2 8 1 20 8 0 104 8 2 8 1 104 8 0 152 8 2 8 1 152 8 0 98 8 2 8 1 98 8 0 183 8 2 8 1 183 8 0 87 8 2 8...
result:
ok
Test #16:
score: 0
Accepted
time: 4ms
memory: 4120kb
input:
196 1 2 1 1 2 1 2 1 2 2 2 1 2 2 2 1 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 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:
8 0 186 8 2 8 0 131 8 2 8 1 131 8 0 138 8 2 8 0 149 8 2 8 0 45 8 2 8 1 45 8 0 83 8 2 8 0 192 8 2 8 1 192 8 0 99 8 2 8 0 25 8 2 8 1 25 8 0 125 8 2 8 1 125 8 0 10 8 2 8 1 10 8 0 179 8 2 8 0 20 8 2 8 1 20 8 0 104 8 2 8 1 104 8 0 152 8 2 8 1 152 8 0 98 8 2 8 0 183 8 2 8 1 183 8 0 87 8 2 8 1 87 8 0 113 8...
result:
ok
Test #17:
score: 0
Accepted
time: 0ms
memory: 3856kb
input:
199 1 1 1 1 2 1 2 2 1 2 1 2 2 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 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:
8 0 187 8 2 8 0 6 8 2 8 0 139 8 2 8 0 110 8 2 8 0 54 8 2 8 1 54 8 0 198 8 2 8 0 193 8 2 8 1 193 8 0 23 8 2 8 1 23 8 0 46 8 2 8 0 66 8 2 8 1 66 8 0 20 8 2 8 0 87 8 2 8 1 87 8 0 92 8 2 8 1 92 8 0 105 8 2 8 1 105 8 0 153 8 2 8 1 153 8 0 99 8 2 8 0 135 8 2 8 0 18 8 2 8 1 18 8 0 43 8 2 8 1 43 8 0 12 8 2 ...
result:
ok
Test #18:
score: 0
Accepted
time: 0ms
memory: 3828kb
input:
196 1 1 1 1 1 2 2 1 2 1 2 1 2 2 2 2 1 2 2 2 2 2 2 1 1 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 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:
8 0 186 8 2 8 0 131 8 2 8 0 138 8 2 8 0 149 8 2 8 0 45 8 2 8 0 83 8 2 8 1 83 8 0 192 8 2 8 1 192 8 0 99 8 2 8 0 25 8 2 8 1 25 8 0 125 8 2 8 0 10 8 2 8 1 10 8 0 179 8 2 8 0 20 8 2 8 1 20 8 0 104 8 2 8 1 104 8 0 152 8 2 8 1 152 8 0 98 8 2 8 1 98 8 0 183 8 2 8 0 87 8 2 8 1 87 8 0 113 8 2 8 1 113 8 0 26...
result:
ok
Test #19:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
196 1 1 1 1 2 1 1 2 2 1 2 2 2 2 2 2 2 1 1 1 1 2 2 2 2 2 1 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 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:
8 0 186 8 2 8 0 131 8 2 8 0 138 8 2 8 0 149 8 2 8 0 45 8 2 8 1 45 8 0 83 8 2 8 0 192 8 2 8 0 99 8 2 8 1 99 8 0 25 8 2 8 1 25 8 0 125 8 2 8 0 10 8 2 8 1 10 8 0 179 8 2 8 1 179 8 0 20 8 2 8 1 20 8 0 104 8 2 8 1 104 8 0 152 8 2 8 1 152 8 0 98 8 2 8 1 98 8 0 183 8 2 8 1 183 8 0 87 8 2 8 0 113 8 2 8 0 26...
result:
ok
Test #20:
score: 0
Accepted
time: 5ms
memory: 3824kb
input:
196 1 1 1 1 2 1 1 2 1 1 2 1 1 2 2 2 1 2 2 2 2 2 2 1 2 1 1 2 2 2 2 2 1 2 2 2 2 2 2 2 2 1 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 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:
8 0 186 8 2 8 0 131 8 2 8 0 138 8 2 8 0 149 8 2 8 0 45 8 2 8 1 45 8 0 83 8 2 8 0 192 8 2 8 0 99 8 2 8 1 99 8 0 25 8 2 8 0 125 8 2 8 0 10 8 2 8 1 10 8 0 179 8 2 8 0 20 8 2 8 0 104 8 2 8 1 104 8 0 152 8 2 8 1 152 8 0 98 8 2 8 1 98 8 0 183 8 2 8 0 87 8 2 8 1 87 8 0 113 8 2 8 1 113 8 0 26 8 2 8 1 26 8 0...
result:
ok
Test #21:
score: 0
Accepted
time: 5ms
memory: 3820kb
input:
200 1 1 1 1 1 1 1 1 1 1 1 2 1 1 2 1 1 1 2 1 2 1 2 1 1 1 1 1 1 1 1 2 2 1 1 1 2 1 2 2 2 2 1 2 2 2 2 1 2 2 2 2 2 2 1 2 2 1 2 2 1 2 2 2 2 1 2 1 2 2 1 2 2 2 2 2 2 1 2 2 2 2 2 1 2 2 1 2 2 2 2 2 2 1 2 2 2 1 2 2 2 2 1 2 2 2 1 2 2 2 2 2 2 1 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 ...
output:
8 0 186 8 2 8 0 131 8 2 8 0 138 8 2 8 0 149 8 2 8 0 45 8 2 8 0 83 8 2 8 0 192 8 2 8 0 99 8 2 8 0 25 8 2 8 0 125 8 2 8 0 10 8 2 8 0 179 8 2 8 1 179 8 0 20 8 2 8 0 104 8 2 8 0 152 8 2 8 1 152 8 0 98 8 2 8 0 183 8 2 8 0 87 8 2 8 0 113 8 2 8 1 113 8 0 26 8 2 8 0 126 8 2 8 1 126 8 0 190 8 2 8 0 90 8 2 8 ...
result:
ok
Test #22:
score: 0
Accepted
time: 5ms
memory: 3880kb
input:
199 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 2 2 1 1 1 1 1 1 1 2 1 2 1 2 1 1 2 1 1 1 1 2 1 1 1 1 1 2 1 1 2 1 1 2 1 2 1 1 1 1 2 1 1 2 2 1 1 2 2 1 1 1 2 1 1 1 2 1 1 1 1 1 1 2 1 1 2 2 1 2 2 2 2 2 2 1 2 2 1 2 2 2 2 2 2 1 1 1 1 1 2 2 1 1 1 2 2 2 2 1 2 2 2 2 2 2 1 2 2 2 1 2 2 2 2 2 2 1 2 2 2 2 2 1 1 2 2 2 2 2 ...
output:
8 0 187 8 2 8 0 6 8 2 8 0 139 8 2 8 0 110 8 2 8 0 54 8 2 8 0 198 8 2 8 0 193 8 2 8 0 23 8 2 8 0 46 8 2 8 1 46 8 0 66 8 2 8 0 20 8 2 8 0 87 8 2 8 0 92 8 2 8 0 105 8 2 8 0 153 8 2 8 0 99 8 2 8 0 135 8 2 8 0 18 8 2 8 0 43 8 2 8 1 43 8 0 12 8 2 8 1 12 8 0 127 8 2 8 0 191 8 2 8 0 22 8 2 8 0 186 8 2 8 0 3...
result:
ok
Test #23:
score: 0
Accepted
time: 2ms
memory: 3820kb
input:
198 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 1 1 2 1 1 2 1 1 1 2 1 1 1 1 1 1 2 1 1 1 2 1 1 1 1 2 1 2 1 1 2 1 1 2 2 1 1 1 1 1 2 1 2 1 2 1 1 1 1 2 1 1 1 2 2 2 2 2 1 2 1 2 1 2 2 2 1 1 2 2 1 2 2 2 1 2 2 2 1 2 1 1 1 1 1 1 2 1 2 1 2 2 1 1 1 ...
output:
8 0 186 8 2 8 0 131 8 2 8 0 138 8 2 8 0 149 8 2 8 0 45 8 2 8 0 83 8 2 8 0 192 8 2 8 0 99 8 2 8 0 25 8 2 8 0 125 8 2 8 0 10 8 2 8 0 179 8 2 8 0 20 8 2 8 0 104 8 2 8 0 152 8 2 8 0 98 8 2 8 0 183 8 2 8 0 87 8 2 8 0 113 8 2 8 0 26 8 2 8 0 126 8 2 8 0 190 8 2 8 0 90 8 2 8 0 89 8 2 8 0 47 8 2 8 0 79 8 2 8...
result:
ok
Subtask #2:
score: 0
Runtime Error
Test #24:
score: 15
Accepted
time: 0ms
memory: 4124kb
input:
1000 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 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:
8 0 186 8 2 8 0 131 8 2 8 1 131 8 0 950 8 2 8 1 950 8 0 700 8 2 8 1 700 8 0 282 8 2 8 1 282 8 0 636 8 2 8 1 636 8 0 192 8 2 8 1 192 8 0 553 8 2 8 1 553 8 0 473 8 2 8 1 473 8 0 223 8 2 8 1 223 8 0 438 8 2 8 1 438 8 0 758 8 2 8 1 758 8 0 404 8 2 8 1 404 8 0 314 8 2 8 1 314 8 0 626 8 2 8 1 626 8 0 961 ...
result:
ok
Test #25:
score: 0
Accepted
time: 0ms
memory: 4156kb
input:
1000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
8 0 186 8 2 8 0 131 8 2 8 0 950 8 2 8 0 700 8 2 8 0 282 8 2 8 0 636 8 2 8 0 192 8 2 8 0 553 8 2 8 0 473 8 2 8 0 223 8 2 8 0 438 8 2 8 0 758 8 2 8 0 404 8 2 8 0 314 8 2 8 0 626 8 2 8 0 961 8 2 8 0 183 8 2 8 0 683 8 2 8 0 420 8 2 8 0 26 8 2 8 0 465 8 2 8 0 566 8 2 8 0 229 8 2 8 0 361 8 2 8 0 731 8 2 8...
result:
ok
Test #26:
score: -15
Runtime Error
input:
output:
result:
Subtask #3:
score: 0
Runtime Error
Test #43:
score: 0
Runtime Error