#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#ifndef LOCAL
#define cerr if(false) cerr
#endif
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
typedef long long ll;
template<class T, template<class T2, class A=allocator<T2> > class cont> inline ostream &operator <<(ostream &out, const cont<T> &x) { for(const auto &it : x) { out << it << " ";} return out;}
template<class T, template<class T2, class A=allocator<T2> > class cont> inline istream &operator >>(istream &in, cont<T> &x) { for(auto &it : x) { in >> it;} return in;}
template<class T, class T2> inline ostream &operator <<(ostream &out, const pair<T, T2> &x) { out << x.first << " " << x.second; return out;}
template<class T, class T2> inline istream &operator >>(istream &in, pair<T, T2> &x) { in >> x.first >> x.second; return in;}
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
ll f(int x) {
if(x == 0) {
return 0;
}
return f(x * 3 / 4) + f(x / 4) + x * 3 / 2;
}
int last = 0;
pair<int, bool> query(int x) {
int now = Query(x);
if(last == now) {
last = now;
return {last, 0};
} else {
last = now;
return {last, 1};
}
}
void daq(vector<int> small, vector<int> big, bool on = false) {
cerr << "Hereeee" << endl;
for(auto it : small) {
cerr << it << " ";
}
cerr << endl;
for(auto it : big) {
cerr << it << " ";
}
cerr << endl;
if(small.size() == 1) {
Answer(small[0], big[0]);
return;
}
if(small.size() == 0) {
return;
}
int m = max(1, (int)(small.size() * 0.40));
for(int i = 0; i < m; i ++) {
query(small[i]);
}
vector<int> ll, lr, rl, rr;
for(int i = 0; i < m; i ++) {
ll.push_back(small[i]);
}
for(int i = m; i < small.size(); i ++) {
rl.push_back(small[i]);
}
for(auto it : big) {
if(lr.size() == m) {
rr.push_back(it);
continue;
} else if(rr.size() == small.size() - m) {
lr.push_back(it);
continue;
}
if(!query(it).second ^ on) {
lr.push_back(it);
} else {
rr.push_back(it);
}
}
daq(ll, lr, !on);
daq(rl, rr, on);
}
void Solve(int n) {
vector<int> l, r;
for(int i = 1; i <= 2 * n; i ++) {
if(query(i).second) {
l.push_back(i);
} else {
r.push_back(i);
}
}
random_shuffle(l.begin(), l.end());
random_shuffle(r.begin(), r.end());
daq(l, r, true);
}
/*
4
1 5
2 6
3 4
7 8
*/
Compilation message
minerals.cpp: In function 'void daq(std::vector<int>, std::vector<int>, bool)':
minerals.cpp:67:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
67 | for(int i = m; i < small.size(); i ++) {
| ~~^~~~~~~~~~~~~~
minerals.cpp:72:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
72 | if(lr.size() == m) {
| ~~~~~~~~~~^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
2 ms |
456 KB |
Output is correct |
3 |
Correct |
4 ms |
636 KB |
Output is correct |
4 |
Correct |
8 ms |
968 KB |
Output is correct |
5 |
Correct |
15 ms |
1480 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
2 ms |
456 KB |
Output is correct |
7 |
Correct |
4 ms |
636 KB |
Output is correct |
8 |
Correct |
8 ms |
968 KB |
Output is correct |
9 |
Correct |
15 ms |
1480 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
10 ms |
1096 KB |
Output is correct |
12 |
Correct |
16 ms |
1560 KB |
Output is correct |
13 |
Correct |
16 ms |
1516 KB |
Output is correct |
14 |
Correct |
16 ms |
1536 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
2 ms |
456 KB |
Output is correct |
7 |
Correct |
4 ms |
636 KB |
Output is correct |
8 |
Correct |
8 ms |
968 KB |
Output is correct |
9 |
Correct |
15 ms |
1480 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
10 ms |
1096 KB |
Output is correct |
12 |
Correct |
16 ms |
1560 KB |
Output is correct |
13 |
Correct |
16 ms |
1516 KB |
Output is correct |
14 |
Correct |
16 ms |
1536 KB |
Output is correct |
15 |
Correct |
49 ms |
3456 KB |
Output is correct |
16 |
Correct |
43 ms |
3472 KB |
Output is correct |
17 |
Correct |
43 ms |
3420 KB |
Output is correct |
18 |
Correct |
42 ms |
3352 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
2 ms |
456 KB |
Output is correct |
7 |
Correct |
4 ms |
636 KB |
Output is correct |
8 |
Correct |
8 ms |
968 KB |
Output is correct |
9 |
Correct |
15 ms |
1480 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
10 ms |
1096 KB |
Output is correct |
12 |
Correct |
16 ms |
1560 KB |
Output is correct |
13 |
Correct |
16 ms |
1516 KB |
Output is correct |
14 |
Correct |
16 ms |
1536 KB |
Output is correct |
15 |
Correct |
49 ms |
3456 KB |
Output is correct |
16 |
Correct |
43 ms |
3472 KB |
Output is correct |
17 |
Correct |
43 ms |
3420 KB |
Output is correct |
18 |
Correct |
42 ms |
3352 KB |
Output is correct |
19 |
Correct |
49 ms |
3476 KB |
Output is correct |
20 |
Correct |
45 ms |
3532 KB |
Output is correct |
21 |
Correct |
43 ms |
3500 KB |
Output is correct |
22 |
Correct |
44 ms |
3320 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
2 ms |
456 KB |
Output is correct |
7 |
Correct |
4 ms |
636 KB |
Output is correct |
8 |
Correct |
8 ms |
968 KB |
Output is correct |
9 |
Correct |
15 ms |
1480 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
10 ms |
1096 KB |
Output is correct |
12 |
Correct |
16 ms |
1560 KB |
Output is correct |
13 |
Correct |
16 ms |
1516 KB |
Output is correct |
14 |
Correct |
16 ms |
1536 KB |
Output is correct |
15 |
Correct |
49 ms |
3456 KB |
Output is correct |
16 |
Correct |
43 ms |
3472 KB |
Output is correct |
17 |
Correct |
43 ms |
3420 KB |
Output is correct |
18 |
Correct |
42 ms |
3352 KB |
Output is correct |
19 |
Correct |
49 ms |
3476 KB |
Output is correct |
20 |
Correct |
45 ms |
3532 KB |
Output is correct |
21 |
Correct |
43 ms |
3500 KB |
Output is correct |
22 |
Correct |
44 ms |
3320 KB |
Output is correct |
23 |
Correct |
47 ms |
3656 KB |
Output is correct |
24 |
Correct |
47 ms |
3660 KB |
Output is correct |
25 |
Correct |
49 ms |
3800 KB |
Output is correct |
26 |
Correct |
48 ms |
3500 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
2 ms |
456 KB |
Output is correct |
7 |
Correct |
4 ms |
636 KB |
Output is correct |
8 |
Correct |
8 ms |
968 KB |
Output is correct |
9 |
Correct |
15 ms |
1480 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
10 ms |
1096 KB |
Output is correct |
12 |
Correct |
16 ms |
1560 KB |
Output is correct |
13 |
Correct |
16 ms |
1516 KB |
Output is correct |
14 |
Correct |
16 ms |
1536 KB |
Output is correct |
15 |
Correct |
49 ms |
3456 KB |
Output is correct |
16 |
Correct |
43 ms |
3472 KB |
Output is correct |
17 |
Correct |
43 ms |
3420 KB |
Output is correct |
18 |
Correct |
42 ms |
3352 KB |
Output is correct |
19 |
Correct |
49 ms |
3476 KB |
Output is correct |
20 |
Correct |
45 ms |
3532 KB |
Output is correct |
21 |
Correct |
43 ms |
3500 KB |
Output is correct |
22 |
Correct |
44 ms |
3320 KB |
Output is correct |
23 |
Correct |
47 ms |
3656 KB |
Output is correct |
24 |
Correct |
47 ms |
3660 KB |
Output is correct |
25 |
Correct |
49 ms |
3800 KB |
Output is correct |
26 |
Correct |
48 ms |
3500 KB |
Output is correct |
27 |
Correct |
51 ms |
3676 KB |
Output is correct |
28 |
Correct |
49 ms |
3700 KB |
Output is correct |
29 |
Correct |
47 ms |
3716 KB |
Output is correct |
30 |
Correct |
45 ms |
3520 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
2 ms |
456 KB |
Output is correct |
7 |
Correct |
4 ms |
636 KB |
Output is correct |
8 |
Correct |
8 ms |
968 KB |
Output is correct |
9 |
Correct |
15 ms |
1480 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
10 ms |
1096 KB |
Output is correct |
12 |
Correct |
16 ms |
1560 KB |
Output is correct |
13 |
Correct |
16 ms |
1516 KB |
Output is correct |
14 |
Correct |
16 ms |
1536 KB |
Output is correct |
15 |
Correct |
49 ms |
3456 KB |
Output is correct |
16 |
Correct |
43 ms |
3472 KB |
Output is correct |
17 |
Correct |
43 ms |
3420 KB |
Output is correct |
18 |
Correct |
42 ms |
3352 KB |
Output is correct |
19 |
Correct |
49 ms |
3476 KB |
Output is correct |
20 |
Correct |
45 ms |
3532 KB |
Output is correct |
21 |
Correct |
43 ms |
3500 KB |
Output is correct |
22 |
Correct |
44 ms |
3320 KB |
Output is correct |
23 |
Correct |
47 ms |
3656 KB |
Output is correct |
24 |
Correct |
47 ms |
3660 KB |
Output is correct |
25 |
Correct |
49 ms |
3800 KB |
Output is correct |
26 |
Correct |
48 ms |
3500 KB |
Output is correct |
27 |
Correct |
51 ms |
3676 KB |
Output is correct |
28 |
Correct |
49 ms |
3700 KB |
Output is correct |
29 |
Correct |
47 ms |
3716 KB |
Output is correct |
30 |
Correct |
45 ms |
3520 KB |
Output is correct |
31 |
Correct |
47 ms |
3796 KB |
Output is correct |
32 |
Correct |
48 ms |
3736 KB |
Output is correct |
33 |
Correct |
46 ms |
3784 KB |
Output is correct |
34 |
Correct |
53 ms |
3548 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
2 ms |
456 KB |
Output is correct |
7 |
Correct |
4 ms |
636 KB |
Output is correct |
8 |
Correct |
8 ms |
968 KB |
Output is correct |
9 |
Correct |
15 ms |
1480 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
10 ms |
1096 KB |
Output is correct |
12 |
Correct |
16 ms |
1560 KB |
Output is correct |
13 |
Correct |
16 ms |
1516 KB |
Output is correct |
14 |
Correct |
16 ms |
1536 KB |
Output is correct |
15 |
Correct |
49 ms |
3456 KB |
Output is correct |
16 |
Correct |
43 ms |
3472 KB |
Output is correct |
17 |
Correct |
43 ms |
3420 KB |
Output is correct |
18 |
Correct |
42 ms |
3352 KB |
Output is correct |
19 |
Correct |
49 ms |
3476 KB |
Output is correct |
20 |
Correct |
45 ms |
3532 KB |
Output is correct |
21 |
Correct |
43 ms |
3500 KB |
Output is correct |
22 |
Correct |
44 ms |
3320 KB |
Output is correct |
23 |
Correct |
47 ms |
3656 KB |
Output is correct |
24 |
Correct |
47 ms |
3660 KB |
Output is correct |
25 |
Correct |
49 ms |
3800 KB |
Output is correct |
26 |
Correct |
48 ms |
3500 KB |
Output is correct |
27 |
Correct |
51 ms |
3676 KB |
Output is correct |
28 |
Correct |
49 ms |
3700 KB |
Output is correct |
29 |
Correct |
47 ms |
3716 KB |
Output is correct |
30 |
Correct |
45 ms |
3520 KB |
Output is correct |
31 |
Correct |
47 ms |
3796 KB |
Output is correct |
32 |
Correct |
48 ms |
3736 KB |
Output is correct |
33 |
Correct |
46 ms |
3784 KB |
Output is correct |
34 |
Correct |
53 ms |
3548 KB |
Output is correct |
35 |
Correct |
56 ms |
3836 KB |
Output is correct |
36 |
Correct |
48 ms |
3816 KB |
Output is correct |
37 |
Correct |
51 ms |
3764 KB |
Output is correct |
38 |
Correct |
47 ms |
3584 KB |
Output is correct |