Submission #994861

#TimeUsernameProblemLanguageResultExecution timeMemory
994861AiperiiiLibrary (JOI18_library)C++14
19 / 100
356 ms600 KiB
#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)

library.cpp: In function 'void Solve(int)':
library.cpp:31:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   31 |     while(res.size()<N){
      |           ~~~~~~~~~~^~
library.cpp:25:14: warning: unused variable 'cnt' [-Wunused-variable]
   25 |     int st=1,cnt=1;
      |              ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...