# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
376753 |
2021-03-12T03:17:23 Z |
8e7 |
Minerals (JOI19_minerals) |
C++14 |
|
32 ms |
3180 KB |
//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 getans(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) {
Answer(a[0], b[0]);
return;
}
int num = 0, mid = (a.size() + 1) / 2;
for (int i = 0;i < mid;i++) {
num = Query(a[i]);
}
vector<int> al, bl, ar, br;
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 = 0;i < mid;i++) {
Query(a[i]);
al.push_back(a[i]);
}
for (int i = mid;i < a.size();i++) ar.push_back(a[i]);
for (int i:b) Query(i);
getans(al, bl);
getans(ar, br);
}
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);
getans(l, r);
}
/*
4
1 5
2 6
3 4
7 8
*/
Compilation message
minerals.cpp: In function 'void getans(std::vector<int>, std::vector<int>)':
minerals.cpp:33:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
33 | for (int i = 0;i < b.size();i++) {
| ~~^~~~~~~~~~
minerals.cpp:46:21: 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 = mid;i < a.size();i++) ar.push_back(a[i]);
| ~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
364 KB |
Output is correct |
2 |
Correct |
3 ms |
492 KB |
Output is correct |
3 |
Correct |
7 ms |
620 KB |
Output is correct |
4 |
Correct |
11 ms |
876 KB |
Output is correct |
5 |
Correct |
19 ms |
1516 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 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 |
7 ms |
620 KB |
Output is correct |
8 |
Correct |
11 ms |
876 KB |
Output is correct |
9 |
Correct |
19 ms |
1516 KB |
Output is correct |
10 |
Correct |
2 ms |
364 KB |
Output is correct |
11 |
Correct |
13 ms |
1132 KB |
Output is correct |
12 |
Correct |
19 ms |
1408 KB |
Output is correct |
13 |
Correct |
17 ms |
1388 KB |
Output is correct |
14 |
Correct |
19 ms |
1388 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 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 |
7 ms |
620 KB |
Output is correct |
8 |
Correct |
11 ms |
876 KB |
Output is correct |
9 |
Correct |
19 ms |
1516 KB |
Output is correct |
10 |
Correct |
2 ms |
364 KB |
Output is correct |
11 |
Correct |
13 ms |
1132 KB |
Output is correct |
12 |
Correct |
19 ms |
1408 KB |
Output is correct |
13 |
Correct |
17 ms |
1388 KB |
Output is correct |
14 |
Correct |
19 ms |
1388 KB |
Output is correct |
15 |
Incorrect |
32 ms |
3180 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 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 |
7 ms |
620 KB |
Output is correct |
8 |
Correct |
11 ms |
876 KB |
Output is correct |
9 |
Correct |
19 ms |
1516 KB |
Output is correct |
10 |
Correct |
2 ms |
364 KB |
Output is correct |
11 |
Correct |
13 ms |
1132 KB |
Output is correct |
12 |
Correct |
19 ms |
1408 KB |
Output is correct |
13 |
Correct |
17 ms |
1388 KB |
Output is correct |
14 |
Correct |
19 ms |
1388 KB |
Output is correct |
15 |
Incorrect |
32 ms |
3180 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 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 |
7 ms |
620 KB |
Output is correct |
8 |
Correct |
11 ms |
876 KB |
Output is correct |
9 |
Correct |
19 ms |
1516 KB |
Output is correct |
10 |
Correct |
2 ms |
364 KB |
Output is correct |
11 |
Correct |
13 ms |
1132 KB |
Output is correct |
12 |
Correct |
19 ms |
1408 KB |
Output is correct |
13 |
Correct |
17 ms |
1388 KB |
Output is correct |
14 |
Correct |
19 ms |
1388 KB |
Output is correct |
15 |
Incorrect |
32 ms |
3180 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 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 |
7 ms |
620 KB |
Output is correct |
8 |
Correct |
11 ms |
876 KB |
Output is correct |
9 |
Correct |
19 ms |
1516 KB |
Output is correct |
10 |
Correct |
2 ms |
364 KB |
Output is correct |
11 |
Correct |
13 ms |
1132 KB |
Output is correct |
12 |
Correct |
19 ms |
1408 KB |
Output is correct |
13 |
Correct |
17 ms |
1388 KB |
Output is correct |
14 |
Correct |
19 ms |
1388 KB |
Output is correct |
15 |
Incorrect |
32 ms |
3180 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 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 |
7 ms |
620 KB |
Output is correct |
8 |
Correct |
11 ms |
876 KB |
Output is correct |
9 |
Correct |
19 ms |
1516 KB |
Output is correct |
10 |
Correct |
2 ms |
364 KB |
Output is correct |
11 |
Correct |
13 ms |
1132 KB |
Output is correct |
12 |
Correct |
19 ms |
1408 KB |
Output is correct |
13 |
Correct |
17 ms |
1388 KB |
Output is correct |
14 |
Correct |
19 ms |
1388 KB |
Output is correct |
15 |
Incorrect |
32 ms |
3180 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 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 |
7 ms |
620 KB |
Output is correct |
8 |
Correct |
11 ms |
876 KB |
Output is correct |
9 |
Correct |
19 ms |
1516 KB |
Output is correct |
10 |
Correct |
2 ms |
364 KB |
Output is correct |
11 |
Correct |
13 ms |
1132 KB |
Output is correct |
12 |
Correct |
19 ms |
1408 KB |
Output is correct |
13 |
Correct |
17 ms |
1388 KB |
Output is correct |
14 |
Correct |
19 ms |
1388 KB |
Output is correct |
15 |
Incorrect |
32 ms |
3180 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |