# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
994861 | Aiperiii | Library (JOI18_library) | C++14 | 356 ms | 600 KiB |
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 <bits/stdc++.h>
#include "library.h"
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
void Solve(int N){
vector <int> g[N+1];
vector <int> x(N),res,used(N+1);
for(int i=1;i<=N;i++){
for(int j=1;j<=N;j++){
if(i!=j && g[i].size()<2 && g[j].size()<2){
x[i-1]=1;x[j-1]=1;
if(g[i].size()==0 or g[i][0]!=j){
if(Query(x)==1){
g[i].pb(j);
g[j].pb(i);
}
}
x[i-1]=0;x[j-1]=0;
}
}
}
int st=1,cnt=1;
for(int i=1;i<=N;i++){
if(g[i].size()==1)st=i;
}
res.pb(st);
used[st]=1;
while(res.size()<N){
for(auto x : g[st]){
if(!used[x]){
res.pb(x);
used[x]=1;
st=x;
}
}
}
Answer(res);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |