이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*
We found Despacito 5 during contest (not clickbait)
*/
#include "grader.h"
#include <vector>
#include <set>
#include <cassert>
using namespace std;
#define cl(a,b) memset(a,b,sizeof(a))
#define all(x) x.begin(),x.end()
#define vec vector
#define vi vec<int>
#define pb push_back
#define f(x,y,z) for(int x=(y); x<(z); x++)
#define fd(x,y,z) for(int x=(y); x>=(z); x--)
#define fit(x,y) for(auto x: y)
#define pii pair<int,int>
#define ppi pair<pii,int>
#define f1 first
#define s2 second
#define spc ' '
#define endl '\n'
bool checkbit(int x,int y){return (x&(1<<y));}
int setbit(int x,int y){return (x^(1<<y));}
const int dirs[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int mod=1e9+7;
const int p1=805306457;
const int p2=1610612741;
const int INF=1e9;
int n;
vi e[16+7];
bool possible[16+7];
vi chosen;
int chosenCnt;
bool chosens[16+7];
int rem;
void dfs(int root, int parent){
chosen.pb(root);
if(possible[root])
chosenCnt++;
chosens[root]=1;
if(abs(rem-chosenCnt)<=1){
return;
}
fit(child,e[root]){
if(child==parent) continue;
dfs(child,root);
if(abs(rem-chosenCnt)<=1){
return;
}
}
}
int findEgg(int N, vector<pii>bridges){
n=N;
assert(n<=16);
fit(x,bridges){
e[x.f1].pb(x.s2);
e[x.s2].pb(x.f1);
}
rem=n;
while(rem>1){
chosen.clear();
cl(chosens,0);
chosenCnt=0;
for(int i=1; i<=n; i++){
if(possible[i]){
dfs(i,0);
break;
}
}
if(query(chosen)){
rem=chosenCnt;
for(int i=1; i<=n; i++)
if(possible[i] && chosens[i]==0)
possible[i]=0;
}
else{
rem-=chosen.size();
for(int i=0; i<chosen.size(); i++)
possible[chosen[i]]=0;
}
}
for(int i=1; i<=n; i++)
if(possible[i])
return i;
}
컴파일 시 표준 에러 (stderr) 메시지
eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:83:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0; i<chosen.size(); i++)
~^~~~~~~~~~~~~~
eastereggs.cpp:90:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |