#include "dango3.h"
#include <bits/stdc++.h>
using namespace std;
int vis[10005];
int N;
int M;
void solve(vector<int> v){
/*printf("solving: ");
for (auto x : v) printf("%d ",x);
printf("\n");*/
int k = v.size()/N;
if (k == 1){
Answer(v);
return;
}
int target = k/2;
int l = 1, r = v.size();
while (l < r){
int m = (l+r)/2;
vector<int> query = vector<int>(v.begin(), v.begin()+m);
/*for (auto x : query) printf("%d ",x);
printf("\n");*/
int res = Query(query);
if (res >= target) r = m;
else l = m+1;
}
set<int> K = set<int>(v.begin(), v.begin()+l);
vector<int> L;
vector<int> R;
for (int i = 0; i < l; i++){
K.erase(v[i]);
vector<int> q;
for (auto x : K) q.push_back(x);
if (Query(q) == target){
R.push_back(v[i]);
}
else {L.push_back(v[i]); K.insert(v[i]);}
}
for (int i = l; i < v.size(); i++) R.push_back(v[i]);
solve(L);
solve(R);
}
void Solve(int _N, int _M) {
N = _N, M = _M;
vector<int> v(N*M);
iota(v.begin(),v.end(),1);
solve(v);
}
Compilation message
dango3.cpp: In function 'void solve(std::vector<int>)':
dango3.cpp:41:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | for (int i = l; i < v.size(); i++) R.push_back(v[i]);
| ~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
440 KB |
Output is correct |
2 |
Correct |
12 ms |
436 KB |
Output is correct |
3 |
Correct |
18 ms |
428 KB |
Output is correct |
4 |
Correct |
18 ms |
420 KB |
Output is correct |
5 |
Correct |
8 ms |
340 KB |
Output is correct |
6 |
Correct |
8 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
258 ms |
608 KB |
Output is correct |
2 |
Correct |
262 ms |
716 KB |
Output is correct |
3 |
Correct |
432 ms |
728 KB |
Output is correct |
4 |
Correct |
432 ms |
724 KB |
Output is correct |
5 |
Correct |
146 ms |
744 KB |
Output is correct |
6 |
Correct |
147 ms |
820 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1064 ms |
996 KB |
Output is correct |
2 |
Correct |
1097 ms |
1172 KB |
Output is correct |
3 |
Correct |
1724 ms |
1080 KB |
Output is correct |
4 |
Correct |
1815 ms |
1160 KB |
Output is correct |
5 |
Correct |
566 ms |
996 KB |
Output is correct |
6 |
Correct |
591 ms |
1156 KB |
Output is correct |