Submission #565905

#TimeUsernameProblemLanguageResultExecution timeMemory
565905errorgornLibrary (JOI18_library)C++17
0 / 100
73 ms344 KiB
#include "library.h" #include <bits/stdc++.h> using namespace std; #define int long long #define ii pair<int,int> #define fi first #define se second #define puf push_front #define pof pop_front #define pub push_back #define pob pop_back #define lb lower_bound #define ub upper_bound #define rep(x,s,e) for (int x=(s)-((s)>(e));x!=(e)-((s)>(e));((s)<(e))?x++:x--) #define all(x) (x).begin(),(x).end() #define sz(x) (int) (x).size() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int n; vector<ii> edges; //what we have found vector<int> al[1005]; bool vis[1005]; vector<signed> ans; void dfs(int i){ vis[i]=true; ans.pub(i); for (auto it:al[i]) if (!vis[it]) dfs(it); } int ask(int l,int r){ set<int> s; rep(x,l,r+1) s.insert(x); vector<signed> v(n,0); for (auto it:s) v[it-1]=1; int res=sz(s)-Query(v); for (auto [a,b]:edges) if (s.count(a) && s.count(b)) res--; return res; } void Solve(signed N){ n=N; rep(x,1,n){ int lo=1,hi=n,mi; while (hi-lo>1){ mi=hi+lo>>1; if (ask(1,mi)) hi=mi; else lo=mi; } int r=hi; lo=1,hi=r,mi; while (hi-lo>1){ mi=hi+lo>>1; if (ask(mi,r)) lo=mi; else hi=mi; } edges.pub({lo,r}); } for (auto [a,b]:edges) al[a].pub(b),al[b].pub(a); rep(x,1,n+1) if (sz(al[x])==1){ dfs(x); break; } //for (auto it:ans) cout<<it<<" "; cout<<endl; Answer(ans); }

Compilation message (stderr)

library.cpp: In function 'void Solve(int)':
library.cpp:55:9: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   55 |    mi=hi+lo>>1;
      |       ~~^~~
library.cpp:61:15: warning: right operand of comma operator has no effect [-Wunused-value]
   61 |   lo=1,hi=r,mi;
      |               ^
library.cpp:63:9: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   63 |    mi=hi+lo>>1;
      |       ~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...