#include "minerals.h"
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define vii vector < pii >
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class P , class Q > ostream& operator<<(ostream& stream, pair < P , Q > v){ stream << "(" << v.fi << ',' << v.se << ")"; return stream;}
template < class T > ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream;}
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
const int N = 1e5 + 5;
int was[N];
void Go(vi a,vi b) {
if (a.size() == 1) {
Answer(a[0],b[0]);
} else
if (a.size() == 2) {
int A = Query(a[0]);
was[a[0]] ^= 1;
int B = Query(b[0]);
was[b[0]] ^= 1;
if (was[a[0]]) {
if (A == B) {
Answer(a[0],b[0]);
Answer(a[1],b[1]);
} else {
Answer(a[0],b[1]);
Answer(a[1],b[0]);
}
} else {
if (A != B) {
Answer(a[0],b[0]);
Answer(a[1],b[1]);
} else {
Answer(a[0],b[1]);
Answer(a[1],b[0]);
}
}
} else {
int sz = a.size();
int m = sz / 2;
int cnt;
for (int i = 0;i < m;++i)
cnt = Query(a[i]),was[a[i]] ^= 1;
vi x1(a.begin(),a.begin() + m),y1,x2(a.begin() + m,a.end()),y2;
int h = was[a[0]];
for (int i = 0;i < sz;++i) {
if (h) {
int cur = Query(b[i]);
was[b[i]] ^= 1;
if (cnt + 1 == cur) {
y2.pb(b[i]);
Query(b[i]);
was[b[i]] ^= 1;
} else {
y1.pb(b[i]);
}
} else {
int cur = Query(b[i]);
was[b[i]] ^= 1;
if (cnt == cur) {
y2.pb(b[i]);
Query(b[i]);
was[b[i]] ^= 1;
} else {
y1.pb(b[i]);
cnt = cur;
}
}
}
Go(x1,y1);
Go(x2,y2);
}
}
void Solve(int N) {
vi a,b;
int cnt = 0;
for (int i = 1;i <= 2 * N;++i) {
int cur = Query(i);
if (cnt + 1 == cur) {
a.pb(i);
} else {
b.pb(i);
}
was[i] = 1;
cnt = cur;
}
Go(a,b);
}
Compilation message
minerals.cpp: In function 'void Go(std::vector<int>, std::vector<int>)':
minerals.cpp:73:5: warning: 'cnt' may be used uninitialized in this function [-Wmaybe-uninitialized]
if (cnt == cur) {
^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
640 KB |
Output is correct |
4 |
Correct |
8 ms |
896 KB |
Output is correct |
5 |
Correct |
14 ms |
1448 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
640 KB |
Output is correct |
8 |
Correct |
8 ms |
896 KB |
Output is correct |
9 |
Correct |
14 ms |
1448 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
10 ms |
1152 KB |
Output is correct |
12 |
Correct |
15 ms |
1456 KB |
Output is correct |
13 |
Correct |
12 ms |
1596 KB |
Output is correct |
14 |
Correct |
12 ms |
1456 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
640 KB |
Output is correct |
8 |
Correct |
8 ms |
896 KB |
Output is correct |
9 |
Correct |
14 ms |
1448 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
10 ms |
1152 KB |
Output is correct |
12 |
Correct |
15 ms |
1456 KB |
Output is correct |
13 |
Correct |
12 ms |
1596 KB |
Output is correct |
14 |
Correct |
12 ms |
1456 KB |
Output is correct |
15 |
Incorrect |
34 ms |
3508 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
640 KB |
Output is correct |
8 |
Correct |
8 ms |
896 KB |
Output is correct |
9 |
Correct |
14 ms |
1448 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
10 ms |
1152 KB |
Output is correct |
12 |
Correct |
15 ms |
1456 KB |
Output is correct |
13 |
Correct |
12 ms |
1596 KB |
Output is correct |
14 |
Correct |
12 ms |
1456 KB |
Output is correct |
15 |
Incorrect |
34 ms |
3508 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
640 KB |
Output is correct |
8 |
Correct |
8 ms |
896 KB |
Output is correct |
9 |
Correct |
14 ms |
1448 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
10 ms |
1152 KB |
Output is correct |
12 |
Correct |
15 ms |
1456 KB |
Output is correct |
13 |
Correct |
12 ms |
1596 KB |
Output is correct |
14 |
Correct |
12 ms |
1456 KB |
Output is correct |
15 |
Incorrect |
34 ms |
3508 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
640 KB |
Output is correct |
8 |
Correct |
8 ms |
896 KB |
Output is correct |
9 |
Correct |
14 ms |
1448 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
10 ms |
1152 KB |
Output is correct |
12 |
Correct |
15 ms |
1456 KB |
Output is correct |
13 |
Correct |
12 ms |
1596 KB |
Output is correct |
14 |
Correct |
12 ms |
1456 KB |
Output is correct |
15 |
Incorrect |
34 ms |
3508 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
640 KB |
Output is correct |
8 |
Correct |
8 ms |
896 KB |
Output is correct |
9 |
Correct |
14 ms |
1448 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
10 ms |
1152 KB |
Output is correct |
12 |
Correct |
15 ms |
1456 KB |
Output is correct |
13 |
Correct |
12 ms |
1596 KB |
Output is correct |
14 |
Correct |
12 ms |
1456 KB |
Output is correct |
15 |
Incorrect |
34 ms |
3508 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
640 KB |
Output is correct |
8 |
Correct |
8 ms |
896 KB |
Output is correct |
9 |
Correct |
14 ms |
1448 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
10 ms |
1152 KB |
Output is correct |
12 |
Correct |
15 ms |
1456 KB |
Output is correct |
13 |
Correct |
12 ms |
1596 KB |
Output is correct |
14 |
Correct |
12 ms |
1456 KB |
Output is correct |
15 |
Incorrect |
34 ms |
3508 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |