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 "chameleon.h"
#include <bits/stdc++.h>
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define svec(x) sort(x.begin(), x.end())
#define press(x) x.erase(unique(x.begin(), x.end()), x.end())
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<int, LL> pil;
typedef pair<LL, int> pli;
const LL llinf=2e18;
const int inf=1e9;
int n, siz[1010];
vector<int> link[1010];
bool ch[1010];
vector<int> vc[2];
int arr[1010];
void Solve(int N){
n=N;
for(int i=1; i<=2*n; i++){
vector<int> qu=vc[1];
qu.eb(i);
if(Query(qu)==qu.size()){
vc[1].eb(i);
arr[i]=1;
}
else vc[0].eb(i);
}
for(int i=1; i<=2*n; i++){
vector<int> nvc;
for(auto j:vc[1-arr[i]]){
if(j<i)nvc.eb(j);
}
while(1){
vector<int> qu=nvc;
qu.eb(i);
if(Query(qu)==qu.size())break;
int l=0, r=nvc.size()-1;
while(l<r) {
int mid=(l+r)/2+1;
vector<int> qu2;
for(int j=mid; j<nvc.size(); j++)qu2.eb(nvc[j]);
qu2.eb(i);
if(Query(qu2)==qu2.size())r=mid-1;
else l=mid;
}
link[i].eb(nvc[l]);
link[nvc[l]].eb(i);
while(nvc.size()>l)nvc.pop_back();
}
}
for(int i=1; i<=2*n; i++){
if(link[i].size()<=2)continue;
assert(link[i].size()==3);
vector<int> qu;
for(int j=0; j<3; j++){
qu.clear();
qu.eb(i);
for(auto k:link[i]){
if(link[i][j]==k)continue;
qu.eb(k);
}
if(Query(qu)==1){
swap(link[i][j], link[i][2]);
link[i].pop_back();
break;
}
}
}
for(int i=1; i<=2*n; i++){
if(ch[i])continue;
for(auto j:link[i]){
bool flg=false;
for(auto k:link[j]){
if(k==i)flg=true;
}
if(flg){
Answer(i, j);
ch[i]=ch[j]=true;
break;
}
}
}
}
Compilation message (stderr)
chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:31:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
31 | if(Query(qu)==qu.size()){
| ~~~~~~~~~^~~~~~~~~~~
chameleon.cpp:45:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
45 | if(Query(qu)==qu.size())break;
| ~~~~~~~~~^~~~~~~~~~~
chameleon.cpp:50:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
50 | for(int j=mid; j<nvc.size(); j++)qu2.eb(nvc[j]);
| ~^~~~~~~~~~~
chameleon.cpp:52:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
52 | if(Query(qu2)==qu2.size())r=mid-1;
| ~~~~~~~~~~^~~~~~~~~~~~
chameleon.cpp:57:29: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
57 | while(nvc.size()>l)nvc.pop_back();
| ~~~~~~~~~~^~
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |