제출 #722363

#제출 시각아이디문제언어결과실행 시간메모리
722363FatihSolak도서관 (JOI18_library)C++17
19 / 100
315 ms368 KiB
#include <bits/stdc++.h> #include "library.h" using namespace std; void Solve(int N){ if(N == 1){ Answer({1}); return; } vector<int> M(N); auto ask = [&](vector<int> &v){ fill(M.begin(),M.end(),0); for(auto u:v){ M[u] = 1; } return Query(M); }; auto ok = [&](vector<int> v,int x)->bool{ if(v.empty()) return false; int tmp = ask(v); v.push_back(x); return ask(v) <= tmp; }; vector<int> adj[N]; vector<bool> used(N); queue<int> q; used[0] = 1; q.push(0); q.push(0); while(q.size()){ int tp = q.front(); q.pop(); vector<int> v; for(int i = 0;i<N;i++){ if(!used[i]) v.push_back(i); } if(!ok(v,tp))continue; while(v.size() > 1){ vector<int> a; while(a.size() < v.size()){ a.push_back(v.back()); v.pop_back(); } if(!ok(v,tp)){ v = a; } } if(!ok(v,tp))continue; q.push(v[0]); used[v[0]] = 1; adj[tp].push_back(v[0]); adj[v[0]].push_back(tp); } if(N > 200){ Answer({}); exit(0); } vector<int> res; for(int i = 0;i<N;i++){ if(adj[i].size() == 1){ int now = i; while(1){ int tmp = -1; if(res.size()) tmp = res.back(); res.push_back(now); if(res.size() == N) break; for(auto u:adj[now]){ if(u != tmp){ now = u; break; } } } break; } } for(auto &u:res) u++; Answer(res); }

컴파일 시 표준 에러 (stderr) 메시지

library.cpp: In function 'void Solve(int)':
library.cpp:68:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   68 |     if(res.size() == N)
      |        ~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...