#include "minerals.h"
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstdlib>
#define X first
#define Y second
#define PB push_back
using namespace std;
typedef long long ll;
typedef pair < int, int > pii;
const int N = 1e5 + 500;
const int MOD = 1e9 + 7;
inline int add(int A, int B){
if(A + B >= MOD)
return A + B - MOD;
return A + B;
}
inline int mul(int A, int B){
return (ll)A * B % MOD;
}
int lo[N], hi[N], p[N], h[N], n;
vector < int > v;
bool cmp(int x, int y){
return h[x] < h[y];
}
void probaj(int tip){
sort(v.begin(), v.end(), cmp);
for(int i = 0;i < 2 * n;){
int j = i;
while(j < 2 * n && h[v[i]] == h[v[j]])
j++;
random_shuffle(v.begin() + i, v.begin() + j);
i = j;
}
int lst = tip * n;
for(int i = 0;i < 2 * n;i++){
int nw = Query(v[i]);
h[v[i]] = add(mul(2, h[v[i]]), abs(nw - lst) ^ p[v[i]]);
lst = nw;
}
}
void Solve(int nn) {
n = nn;
int lst = 0;
for(int i = 1;i <= 2 * n;i++){
int nw = Query(i);
p[i] = nw - lst;
v.PB(i);
lst = nw;
}
for(int sad = 1, pitaj = 2 * n;pitaj + 2 * n <= 1e6; pitaj += 2 * n, sad = !sad)
probaj(sad);
sort(v.begin(), v.end(), cmp);
for(int i = 0;i < n;i++){
// printf("%d %d : %d %d\n", v[2 * i], v[2 * i + 1], h[v[2 * i]], h[v[2 * i + 1]]);
Answer(v[2 * i], v[2 * i + 1]);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
48 ms |
256 KB |
Output is correct |
2 |
Correct |
49 ms |
368 KB |
Output is correct |
3 |
Correct |
67 ms |
376 KB |
Output is correct |
4 |
Correct |
68 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
94 ms |
504 KB |
Output is correct |
2 |
Correct |
101 ms |
384 KB |
Output is correct |
3 |
Correct |
111 ms |
632 KB |
Output is correct |
4 |
Correct |
112 ms |
768 KB |
Output is correct |
5 |
Correct |
99 ms |
1272 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
48 ms |
256 KB |
Output is correct |
2 |
Correct |
49 ms |
368 KB |
Output is correct |
3 |
Correct |
67 ms |
376 KB |
Output is correct |
4 |
Correct |
68 ms |
384 KB |
Output is correct |
5 |
Correct |
94 ms |
504 KB |
Output is correct |
6 |
Correct |
101 ms |
384 KB |
Output is correct |
7 |
Correct |
111 ms |
632 KB |
Output is correct |
8 |
Correct |
112 ms |
768 KB |
Output is correct |
9 |
Correct |
99 ms |
1272 KB |
Output is correct |
10 |
Correct |
97 ms |
384 KB |
Output is correct |
11 |
Correct |
113 ms |
1016 KB |
Output is correct |
12 |
Correct |
98 ms |
1276 KB |
Output is correct |
13 |
Correct |
95 ms |
1272 KB |
Output is correct |
14 |
Incorrect |
95 ms |
1156 KB |
Wrong Answer [5] |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
48 ms |
256 KB |
Output is correct |
2 |
Correct |
49 ms |
368 KB |
Output is correct |
3 |
Correct |
67 ms |
376 KB |
Output is correct |
4 |
Correct |
68 ms |
384 KB |
Output is correct |
5 |
Correct |
94 ms |
504 KB |
Output is correct |
6 |
Correct |
101 ms |
384 KB |
Output is correct |
7 |
Correct |
111 ms |
632 KB |
Output is correct |
8 |
Correct |
112 ms |
768 KB |
Output is correct |
9 |
Correct |
99 ms |
1272 KB |
Output is correct |
10 |
Correct |
97 ms |
384 KB |
Output is correct |
11 |
Correct |
113 ms |
1016 KB |
Output is correct |
12 |
Correct |
98 ms |
1276 KB |
Output is correct |
13 |
Correct |
95 ms |
1272 KB |
Output is correct |
14 |
Incorrect |
95 ms |
1156 KB |
Wrong Answer [5] |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
48 ms |
256 KB |
Output is correct |
2 |
Correct |
49 ms |
368 KB |
Output is correct |
3 |
Correct |
67 ms |
376 KB |
Output is correct |
4 |
Correct |
68 ms |
384 KB |
Output is correct |
5 |
Correct |
94 ms |
504 KB |
Output is correct |
6 |
Correct |
101 ms |
384 KB |
Output is correct |
7 |
Correct |
111 ms |
632 KB |
Output is correct |
8 |
Correct |
112 ms |
768 KB |
Output is correct |
9 |
Correct |
99 ms |
1272 KB |
Output is correct |
10 |
Correct |
97 ms |
384 KB |
Output is correct |
11 |
Correct |
113 ms |
1016 KB |
Output is correct |
12 |
Correct |
98 ms |
1276 KB |
Output is correct |
13 |
Correct |
95 ms |
1272 KB |
Output is correct |
14 |
Incorrect |
95 ms |
1156 KB |
Wrong Answer [5] |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
48 ms |
256 KB |
Output is correct |
2 |
Correct |
49 ms |
368 KB |
Output is correct |
3 |
Correct |
67 ms |
376 KB |
Output is correct |
4 |
Correct |
68 ms |
384 KB |
Output is correct |
5 |
Correct |
94 ms |
504 KB |
Output is correct |
6 |
Correct |
101 ms |
384 KB |
Output is correct |
7 |
Correct |
111 ms |
632 KB |
Output is correct |
8 |
Correct |
112 ms |
768 KB |
Output is correct |
9 |
Correct |
99 ms |
1272 KB |
Output is correct |
10 |
Correct |
97 ms |
384 KB |
Output is correct |
11 |
Correct |
113 ms |
1016 KB |
Output is correct |
12 |
Correct |
98 ms |
1276 KB |
Output is correct |
13 |
Correct |
95 ms |
1272 KB |
Output is correct |
14 |
Incorrect |
95 ms |
1156 KB |
Wrong Answer [5] |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
48 ms |
256 KB |
Output is correct |
2 |
Correct |
49 ms |
368 KB |
Output is correct |
3 |
Correct |
67 ms |
376 KB |
Output is correct |
4 |
Correct |
68 ms |
384 KB |
Output is correct |
5 |
Correct |
94 ms |
504 KB |
Output is correct |
6 |
Correct |
101 ms |
384 KB |
Output is correct |
7 |
Correct |
111 ms |
632 KB |
Output is correct |
8 |
Correct |
112 ms |
768 KB |
Output is correct |
9 |
Correct |
99 ms |
1272 KB |
Output is correct |
10 |
Correct |
97 ms |
384 KB |
Output is correct |
11 |
Correct |
113 ms |
1016 KB |
Output is correct |
12 |
Correct |
98 ms |
1276 KB |
Output is correct |
13 |
Correct |
95 ms |
1272 KB |
Output is correct |
14 |
Incorrect |
95 ms |
1156 KB |
Wrong Answer [5] |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
48 ms |
256 KB |
Output is correct |
2 |
Correct |
49 ms |
368 KB |
Output is correct |
3 |
Correct |
67 ms |
376 KB |
Output is correct |
4 |
Correct |
68 ms |
384 KB |
Output is correct |
5 |
Correct |
94 ms |
504 KB |
Output is correct |
6 |
Correct |
101 ms |
384 KB |
Output is correct |
7 |
Correct |
111 ms |
632 KB |
Output is correct |
8 |
Correct |
112 ms |
768 KB |
Output is correct |
9 |
Correct |
99 ms |
1272 KB |
Output is correct |
10 |
Correct |
97 ms |
384 KB |
Output is correct |
11 |
Correct |
113 ms |
1016 KB |
Output is correct |
12 |
Correct |
98 ms |
1276 KB |
Output is correct |
13 |
Correct |
95 ms |
1272 KB |
Output is correct |
14 |
Incorrect |
95 ms |
1156 KB |
Wrong Answer [5] |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
48 ms |
256 KB |
Output is correct |
2 |
Correct |
49 ms |
368 KB |
Output is correct |
3 |
Correct |
67 ms |
376 KB |
Output is correct |
4 |
Correct |
68 ms |
384 KB |
Output is correct |
5 |
Correct |
94 ms |
504 KB |
Output is correct |
6 |
Correct |
101 ms |
384 KB |
Output is correct |
7 |
Correct |
111 ms |
632 KB |
Output is correct |
8 |
Correct |
112 ms |
768 KB |
Output is correct |
9 |
Correct |
99 ms |
1272 KB |
Output is correct |
10 |
Correct |
97 ms |
384 KB |
Output is correct |
11 |
Correct |
113 ms |
1016 KB |
Output is correct |
12 |
Correct |
98 ms |
1276 KB |
Output is correct |
13 |
Correct |
95 ms |
1272 KB |
Output is correct |
14 |
Incorrect |
95 ms |
1156 KB |
Wrong Answer [5] |