This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "dango3.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("Ofast,unroll-loops")
#define pii pair<int,int>
using namespace __gnu_pbds;
using namespace std;
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define f first
#define s second
#define pii pair<int,int>
template<class T>bool umax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T>bool umin(T &a,T b){if(b<a){a=b;return true;}return false;}
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
const int mod= 1e9 +7;
const int N=1e5*4;
void Solve(int n,int m){
vector<int>v(n*m);
for(int i = 1;i<=n*m;i++){
v.pb(i);
}
queue<pair<vector<int>,int>>q;
q.push({v,m});
while(!q.empty()){
auto [g,sz] = q.front();
q.pop();
if(sz==1){
Answer(g);
continue;
}
vector<int>vs;
for(int i = 0;i<g.size();i++){
vs.pb(g[0]);
g.erase(g.begin());
int x = Query(g);
if(x<sz/2){
g.pb(vs.back());
vs.pop_back();
}
}
q.push({g,m/2});
q.push({vs,(m+1)/2});
}
}
Compilation message (stderr)
dango3.cpp: In function 'void Solve(int, int)':
dango3.cpp:46:18: 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<g.size();i++){
| ~^~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |