//Challenge: Accepted
#include "minerals.h"
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#define ll long long
#define maxn 100005
#define pii pair<int, int>
#define ff first
#define ss second
#define io ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
int tot;
void solvebyadd(vector<int> a, vector<int> b);
void solvebydel(vector<int> a, vector<int> b);
void Solve(int N) {
tot = N;
int num = 0;
vector<int> l, r;
for (int i = 1;i <= 2 * N;i++) {
int tmp = Query(i);
if (tmp != num) l.push_back(i);
else r.push_back(i);
num = tmp;
}
//for (int i = 1;i <= 2 * N;i++) Query(i);
solvebydel(l, r);
}
void solvebyadd(vector<int> a, vector<int> b) {
//initially empty
if (a.size() < 1) return;
if (a.size() == 1) {
Answer(a[0], b[0]);
return;
}
vector<int> al, bl, ar, br;
int num = 0, mid = (a.size() + 1) / 2;
for (int i = 0;i < mid;i++) {
num = Query(a[i]);
al.push_back(a[i]);
}
for (int i = 0;i < b.size();i++) {
int tmp = Query(b[i]);
if (tmp == num) {
bl.push_back(b[i]);
} else {
br.push_back(b[i]);
}
num = tmp;
}
for (int i = mid;i < a.size();i++) ar.push_back(a[i]);
for (int i:br) Query(i);
solvebydel(al, bl);
solvebyadd(ar, br);
}
void solvebydel(vector<int> a, vector<int> b) {
//for (int i:a) cout << i << " ";
//cout << endl;
//for (int i:b) cout << i << " ";
//cout << endl;
//cout << endl;
if (a.size() < 1) return;
if (a.size() == 1) { //look here
Query(a[0]), Query(b[0]);
Answer(a[0], b[0]);
return;
}
vector<int> al, bl, ar, br;
int num = 0, mid = (a.size() + 1) / 2;
for (int i = 0;i < mid;i++) al.push_back(a[i]);
for (int i = mid;i < a.size();i++) {
num = Query(a[i]);
ar.push_back(a[i]);
}
for (int i = 0;i < b.size();i++) {
int tmp = Query(b[i]);
if (tmp == num) {
bl.push_back(b[i]);
} else {
br.push_back(b[i]);
}
num = tmp;
}
for (int i:bl) Query(i);
solvebydel(al, bl);
solvebyadd(ar, br);
/*
for (int i:ar) Query(i);
for (int i:br) Query(i);
getans(ar, br);
*/
}
/*
4
1 5
2 6
3 4
7 8
*/
Compilation message
minerals.cpp: In function 'void solvebyadd(std::vector<int>, std::vector<int>)':
minerals.cpp:46:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
46 | for (int i = 0;i < b.size();i++) {
| ~~^~~~~~~~~~
minerals.cpp:55:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
55 | for (int i = mid;i < a.size();i++) ar.push_back(a[i]);
| ~~^~~~~~~~~~
minerals.cpp: In function 'void solvebydel(std::vector<int>, std::vector<int>)':
minerals.cpp:79:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
79 | for (int i = mid;i < a.size();i++) {
| ~~^~~~~~~~~~
minerals.cpp:84:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
84 | for (int i = 0;i < b.size();i++) {
| ~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
364 KB |
Output is correct |
2 |
Correct |
3 ms |
492 KB |
Output is correct |
3 |
Correct |
5 ms |
620 KB |
Output is correct |
4 |
Correct |
9 ms |
876 KB |
Output is correct |
5 |
Correct |
18 ms |
1388 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
364 KB |
Output is correct |
6 |
Correct |
3 ms |
492 KB |
Output is correct |
7 |
Correct |
5 ms |
620 KB |
Output is correct |
8 |
Correct |
9 ms |
876 KB |
Output is correct |
9 |
Correct |
18 ms |
1388 KB |
Output is correct |
10 |
Correct |
2 ms |
364 KB |
Output is correct |
11 |
Correct |
16 ms |
1132 KB |
Output is correct |
12 |
Correct |
18 ms |
1388 KB |
Output is correct |
13 |
Correct |
16 ms |
1388 KB |
Output is correct |
14 |
Correct |
22 ms |
1388 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
364 KB |
Output is correct |
6 |
Correct |
3 ms |
492 KB |
Output is correct |
7 |
Correct |
5 ms |
620 KB |
Output is correct |
8 |
Correct |
9 ms |
876 KB |
Output is correct |
9 |
Correct |
18 ms |
1388 KB |
Output is correct |
10 |
Correct |
2 ms |
364 KB |
Output is correct |
11 |
Correct |
16 ms |
1132 KB |
Output is correct |
12 |
Correct |
18 ms |
1388 KB |
Output is correct |
13 |
Correct |
16 ms |
1388 KB |
Output is correct |
14 |
Correct |
22 ms |
1388 KB |
Output is correct |
15 |
Incorrect |
50 ms |
3228 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
364 KB |
Output is correct |
6 |
Correct |
3 ms |
492 KB |
Output is correct |
7 |
Correct |
5 ms |
620 KB |
Output is correct |
8 |
Correct |
9 ms |
876 KB |
Output is correct |
9 |
Correct |
18 ms |
1388 KB |
Output is correct |
10 |
Correct |
2 ms |
364 KB |
Output is correct |
11 |
Correct |
16 ms |
1132 KB |
Output is correct |
12 |
Correct |
18 ms |
1388 KB |
Output is correct |
13 |
Correct |
16 ms |
1388 KB |
Output is correct |
14 |
Correct |
22 ms |
1388 KB |
Output is correct |
15 |
Incorrect |
50 ms |
3228 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
364 KB |
Output is correct |
6 |
Correct |
3 ms |
492 KB |
Output is correct |
7 |
Correct |
5 ms |
620 KB |
Output is correct |
8 |
Correct |
9 ms |
876 KB |
Output is correct |
9 |
Correct |
18 ms |
1388 KB |
Output is correct |
10 |
Correct |
2 ms |
364 KB |
Output is correct |
11 |
Correct |
16 ms |
1132 KB |
Output is correct |
12 |
Correct |
18 ms |
1388 KB |
Output is correct |
13 |
Correct |
16 ms |
1388 KB |
Output is correct |
14 |
Correct |
22 ms |
1388 KB |
Output is correct |
15 |
Incorrect |
50 ms |
3228 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
364 KB |
Output is correct |
6 |
Correct |
3 ms |
492 KB |
Output is correct |
7 |
Correct |
5 ms |
620 KB |
Output is correct |
8 |
Correct |
9 ms |
876 KB |
Output is correct |
9 |
Correct |
18 ms |
1388 KB |
Output is correct |
10 |
Correct |
2 ms |
364 KB |
Output is correct |
11 |
Correct |
16 ms |
1132 KB |
Output is correct |
12 |
Correct |
18 ms |
1388 KB |
Output is correct |
13 |
Correct |
16 ms |
1388 KB |
Output is correct |
14 |
Correct |
22 ms |
1388 KB |
Output is correct |
15 |
Incorrect |
50 ms |
3228 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
364 KB |
Output is correct |
6 |
Correct |
3 ms |
492 KB |
Output is correct |
7 |
Correct |
5 ms |
620 KB |
Output is correct |
8 |
Correct |
9 ms |
876 KB |
Output is correct |
9 |
Correct |
18 ms |
1388 KB |
Output is correct |
10 |
Correct |
2 ms |
364 KB |
Output is correct |
11 |
Correct |
16 ms |
1132 KB |
Output is correct |
12 |
Correct |
18 ms |
1388 KB |
Output is correct |
13 |
Correct |
16 ms |
1388 KB |
Output is correct |
14 |
Correct |
22 ms |
1388 KB |
Output is correct |
15 |
Incorrect |
50 ms |
3228 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
364 KB |
Output is correct |
6 |
Correct |
3 ms |
492 KB |
Output is correct |
7 |
Correct |
5 ms |
620 KB |
Output is correct |
8 |
Correct |
9 ms |
876 KB |
Output is correct |
9 |
Correct |
18 ms |
1388 KB |
Output is correct |
10 |
Correct |
2 ms |
364 KB |
Output is correct |
11 |
Correct |
16 ms |
1132 KB |
Output is correct |
12 |
Correct |
18 ms |
1388 KB |
Output is correct |
13 |
Correct |
16 ms |
1388 KB |
Output is correct |
14 |
Correct |
22 ms |
1388 KB |
Output is correct |
15 |
Incorrect |
50 ms |
3228 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |