#include "dango3.h"
#define here cerr<<"===========================================\n"
#define dbg(x) cerr<<#x<<": "<<x<<endl;
#include "bits/stdc++.h"
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
#define ld double
#define ll int
#define llinf 100000000000000000LL // 10^17
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define endl '\n'
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define all(a) a.begin(),a.end()
#define ceri(a,l,r) {cerr<<#a<<": ";for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;}
#define cer(a) {cerr<<#a<<": ";for(ll x_ : a) cerr<<x_<< " ";cerr<<endl;}
#define daj_mi_malo_vremena ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0);
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll rnd(ll l,ll r){
return uniform_int_distribution<ll>(l,r)(rng);
}
#define maxn 405
#define maxm 30
ll n,m;
bool ok[maxn*maxm];
vector<ll> w;
ll ask(){
w.clear();
for(ll i = 1;i<=n*m;i++) if(!ok[i]) w.pb(i);
return m-Query(w);
}
vector<ll> ans[maxm];
void Solve(int N, int M) {
n = N; m = M;
for(ll i = 1;i<=n*m;i++){
ll l = 1,r = m,mid,rez = 0;
ok[i] = 1;
while(l<=r){
mid = (l+r)/2;
for(ll x : ans[mid]) ok[x] = 1;
if(ask()==1){
rez = mid;
r = mid-1;
}else l = mid+1;
for(ll x : ans[mid]) ok[x] = 0;
}
ans[rez].pb(i);
ok[i] = 0;
}
for(ll i = 1;i<=m;i++) Answer(ans[i]);
}
/**
3 2
3 3 1 2 1 2
4 4
2 2 3 2 4 4 3 2 3 1 1 3 4 1 4 1
**/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
0 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 |
33 ms |
340 KB |
Output is correct |
2 |
Correct |
34 ms |
340 KB |
Output is correct |
3 |
Correct |
28 ms |
372 KB |
Output is correct |
4 |
Correct |
28 ms |
364 KB |
Output is correct |
5 |
Correct |
29 ms |
368 KB |
Output is correct |
6 |
Correct |
30 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
921 ms |
412 KB |
Output is correct |
2 |
Correct |
954 ms |
544 KB |
Output is correct |
3 |
Correct |
1008 ms |
548 KB |
Output is correct |
4 |
Correct |
977 ms |
432 KB |
Output is correct |
5 |
Correct |
947 ms |
420 KB |
Output is correct |
6 |
Correct |
853 ms |
420 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3966 ms |
492 KB |
Output is correct |
2 |
Correct |
3858 ms |
492 KB |
Output is correct |
3 |
Correct |
3743 ms |
632 KB |
Output is correct |
4 |
Correct |
3742 ms |
500 KB |
Output is correct |
5 |
Correct |
3763 ms |
492 KB |
Output is correct |
6 |
Correct |
3851 ms |
496 KB |
Output is correct |