이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#include "chameleon.h"
void Solve(int n){
if(n<=50){
vector<pair<int,int> > eds,adj[2*n+1];
vector<int> st;
for(int i=1; i<2*n; i++){
for(int j=i+1; j<=2*n; j++){
int x=Query({i,j});
if(x==1){
eds.push_back({i,j});
adj[i].push_back({j,eds.size()-1});
adj[j].push_back({i,eds.size()-1});
st.push_back(0);
}
}
}
for(int i=1; i<=2*n; i++){
if((int)adj[i].size()==1) continue;
assert((int)adj[i].size()==3);
int a=Query({i,adj[i][0].first,adj[i][1].first});
int b=Query({i,adj[i][0].first,adj[i][2].first});
int c=Query({i,adj[i][1].first,adj[i][2].first});
if(a==1) st[adj[i][2].second]=1;
if(b==1) st[adj[i][1].second]=1;
if(c==1) st[adj[i][0].second]=1;
}
for(int i=0; i<(int)eds.size(); i++){
if(st[i]==0) Answer(eds[i].first,eds[i].second);
}
}
else{
vector<int> v;
int got[2*n+1];
memset(got,0,sizeof(got));
for(int i=1; i<=2*n; i++){
v.clear();
for(int j=1; j<=i; j++) if(!got[j]) v.push_back(j);
int x=Query(v);
if(x<(int)v.size()){
int lo=1,hi=i-1,mid;
while(lo<hi){
mid=(lo+hi)/2;
v.clear();
v.push_back(i);
for(int j=lo; j<=mid; j++) if(!got[j]) v.push_back(j);
x=Query(v);
if(x<(int)v.size()) hi=mid;
else lo=mid+1;
}
Answer(lo,i);
got[lo]=1;
got[i]=1;
}
}
}
}
# | 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... |