#include "minerals.h"
#include <vector>
using namespace std;
int l[43000], r[43000],m[43000];
int ans[43000];
void Solve(int N) {
int NN = N + N;
int last = 0;
vector<int> X,Y;
for (int i = 1; i <= NN; ++i) {
int in = Query(i);
if (in == last) {
int yix = Y.size();
l[yix] = 0, r[yix] = X.size() - 1;
Y.push_back(i);
}
else X.push_back(i);
last = in;
}
int dir = 1;
while (1) {
vector<int> v[43000];//ix li
int in = 0;
for (int i = 0; i < N; ++i) {
if (l[i] <= r[i]) {
m[i] = (l[i] + r[i]) >> 1;
v[m[i]].push_back(i);//yix
++in;
}
}
if (in == 0) break;
if (dir) {
for (int i = N - 1; i >= 0; --i) {
for (auto yix : v[i]) {
int y = Y[yix];
in = Query(y);
if (in == last) r[yix] = i - 1, ans[yix] = i;
else l[yix] = i + 1;
last = in;
}
last = Query(X[i]);
}
}
else {
for (int i = 0; i < N; ++i) {
last = Query(X[i]);
for (auto yix : v[i]) {
int y = Y[yix];
in = Query(y);
if (in == last) r[yix] = i - 1, ans[yix] = i;
else l[yix] = i + 1;
last = in;
}
}
}
dir = 1 - dir;
}
for (int i = 0; i < N; ++i)
Answer(X[ans[i]],Y[i]);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1400 KB |
Output is correct |
2 |
Correct |
3 ms |
1276 KB |
Output is correct |
3 |
Correct |
4 ms |
1400 KB |
Output is correct |
4 |
Correct |
3 ms |
1272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1400 KB |
Output is correct |
2 |
Correct |
7 ms |
1532 KB |
Output is correct |
3 |
Correct |
8 ms |
1528 KB |
Output is correct |
4 |
Correct |
14 ms |
1784 KB |
Output is correct |
5 |
Correct |
25 ms |
2296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1400 KB |
Output is correct |
2 |
Correct |
3 ms |
1276 KB |
Output is correct |
3 |
Correct |
4 ms |
1400 KB |
Output is correct |
4 |
Correct |
3 ms |
1272 KB |
Output is correct |
5 |
Correct |
5 ms |
1400 KB |
Output is correct |
6 |
Correct |
7 ms |
1532 KB |
Output is correct |
7 |
Correct |
8 ms |
1528 KB |
Output is correct |
8 |
Correct |
14 ms |
1784 KB |
Output is correct |
9 |
Correct |
25 ms |
2296 KB |
Output is correct |
10 |
Correct |
5 ms |
1400 KB |
Output is correct |
11 |
Correct |
26 ms |
2168 KB |
Output is correct |
12 |
Correct |
40 ms |
2552 KB |
Output is correct |
13 |
Correct |
24 ms |
2600 KB |
Output is correct |
14 |
Correct |
19 ms |
2296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1400 KB |
Output is correct |
2 |
Correct |
3 ms |
1276 KB |
Output is correct |
3 |
Correct |
4 ms |
1400 KB |
Output is correct |
4 |
Correct |
3 ms |
1272 KB |
Output is correct |
5 |
Correct |
5 ms |
1400 KB |
Output is correct |
6 |
Correct |
7 ms |
1532 KB |
Output is correct |
7 |
Correct |
8 ms |
1528 KB |
Output is correct |
8 |
Correct |
14 ms |
1784 KB |
Output is correct |
9 |
Correct |
25 ms |
2296 KB |
Output is correct |
10 |
Correct |
5 ms |
1400 KB |
Output is correct |
11 |
Correct |
26 ms |
2168 KB |
Output is correct |
12 |
Correct |
40 ms |
2552 KB |
Output is correct |
13 |
Correct |
24 ms |
2600 KB |
Output is correct |
14 |
Correct |
19 ms |
2296 KB |
Output is correct |
15 |
Incorrect |
96 ms |
3924 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1400 KB |
Output is correct |
2 |
Correct |
3 ms |
1276 KB |
Output is correct |
3 |
Correct |
4 ms |
1400 KB |
Output is correct |
4 |
Correct |
3 ms |
1272 KB |
Output is correct |
5 |
Correct |
5 ms |
1400 KB |
Output is correct |
6 |
Correct |
7 ms |
1532 KB |
Output is correct |
7 |
Correct |
8 ms |
1528 KB |
Output is correct |
8 |
Correct |
14 ms |
1784 KB |
Output is correct |
9 |
Correct |
25 ms |
2296 KB |
Output is correct |
10 |
Correct |
5 ms |
1400 KB |
Output is correct |
11 |
Correct |
26 ms |
2168 KB |
Output is correct |
12 |
Correct |
40 ms |
2552 KB |
Output is correct |
13 |
Correct |
24 ms |
2600 KB |
Output is correct |
14 |
Correct |
19 ms |
2296 KB |
Output is correct |
15 |
Incorrect |
96 ms |
3924 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1400 KB |
Output is correct |
2 |
Correct |
3 ms |
1276 KB |
Output is correct |
3 |
Correct |
4 ms |
1400 KB |
Output is correct |
4 |
Correct |
3 ms |
1272 KB |
Output is correct |
5 |
Correct |
5 ms |
1400 KB |
Output is correct |
6 |
Correct |
7 ms |
1532 KB |
Output is correct |
7 |
Correct |
8 ms |
1528 KB |
Output is correct |
8 |
Correct |
14 ms |
1784 KB |
Output is correct |
9 |
Correct |
25 ms |
2296 KB |
Output is correct |
10 |
Correct |
5 ms |
1400 KB |
Output is correct |
11 |
Correct |
26 ms |
2168 KB |
Output is correct |
12 |
Correct |
40 ms |
2552 KB |
Output is correct |
13 |
Correct |
24 ms |
2600 KB |
Output is correct |
14 |
Correct |
19 ms |
2296 KB |
Output is correct |
15 |
Incorrect |
96 ms |
3924 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1400 KB |
Output is correct |
2 |
Correct |
3 ms |
1276 KB |
Output is correct |
3 |
Correct |
4 ms |
1400 KB |
Output is correct |
4 |
Correct |
3 ms |
1272 KB |
Output is correct |
5 |
Correct |
5 ms |
1400 KB |
Output is correct |
6 |
Correct |
7 ms |
1532 KB |
Output is correct |
7 |
Correct |
8 ms |
1528 KB |
Output is correct |
8 |
Correct |
14 ms |
1784 KB |
Output is correct |
9 |
Correct |
25 ms |
2296 KB |
Output is correct |
10 |
Correct |
5 ms |
1400 KB |
Output is correct |
11 |
Correct |
26 ms |
2168 KB |
Output is correct |
12 |
Correct |
40 ms |
2552 KB |
Output is correct |
13 |
Correct |
24 ms |
2600 KB |
Output is correct |
14 |
Correct |
19 ms |
2296 KB |
Output is correct |
15 |
Incorrect |
96 ms |
3924 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1400 KB |
Output is correct |
2 |
Correct |
3 ms |
1276 KB |
Output is correct |
3 |
Correct |
4 ms |
1400 KB |
Output is correct |
4 |
Correct |
3 ms |
1272 KB |
Output is correct |
5 |
Correct |
5 ms |
1400 KB |
Output is correct |
6 |
Correct |
7 ms |
1532 KB |
Output is correct |
7 |
Correct |
8 ms |
1528 KB |
Output is correct |
8 |
Correct |
14 ms |
1784 KB |
Output is correct |
9 |
Correct |
25 ms |
2296 KB |
Output is correct |
10 |
Correct |
5 ms |
1400 KB |
Output is correct |
11 |
Correct |
26 ms |
2168 KB |
Output is correct |
12 |
Correct |
40 ms |
2552 KB |
Output is correct |
13 |
Correct |
24 ms |
2600 KB |
Output is correct |
14 |
Correct |
19 ms |
2296 KB |
Output is correct |
15 |
Incorrect |
96 ms |
3924 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1400 KB |
Output is correct |
2 |
Correct |
3 ms |
1276 KB |
Output is correct |
3 |
Correct |
4 ms |
1400 KB |
Output is correct |
4 |
Correct |
3 ms |
1272 KB |
Output is correct |
5 |
Correct |
5 ms |
1400 KB |
Output is correct |
6 |
Correct |
7 ms |
1532 KB |
Output is correct |
7 |
Correct |
8 ms |
1528 KB |
Output is correct |
8 |
Correct |
14 ms |
1784 KB |
Output is correct |
9 |
Correct |
25 ms |
2296 KB |
Output is correct |
10 |
Correct |
5 ms |
1400 KB |
Output is correct |
11 |
Correct |
26 ms |
2168 KB |
Output is correct |
12 |
Correct |
40 ms |
2552 KB |
Output is correct |
13 |
Correct |
24 ms |
2600 KB |
Output is correct |
14 |
Correct |
19 ms |
2296 KB |
Output is correct |
15 |
Incorrect |
96 ms |
3924 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |