Submission #654376

#TimeUsernameProblemLanguageResultExecution timeMemory
654376Tuanlinh123Library (JOI18_library)C++17
0 / 100
203 ms316 KiB
#include "library.h" #include<bits/stdc++.h> #define ll int #define ld long double #define pll pair<ll,ll> #define mp make_pair #define pb push_back #define fi first #define se second using namespace std; #define LOCALIO "C:/Users/admin/Documents/Code/" #define maxn 1005 ll n; vector <ll> ans[maxn]; ll calc(ll idx, ll l, ll r) { ll q1=0, q2=0; vector <ll> m; m.assign(n, 0); for (ll i=l; i<=r; i++) m[i-1]=1; q1=Query(m); m[idx-1]=1; q2=Query(m); return q1+1-q2; } void Find(ll idx, ll l, ll r) { if (r<l) return; ll mid=(l+r)/2, q=calc(idx, l, r); if (calc(idx, l, r)==0) return; if (l==r) { ans[idx].pb(l); return; } Find(idx, l, mid); Find(idx, mid+1, r); } ll findstart() { for (ll i=1; i<=n; i++) if (ans[i].size()==1) return i; return 0; } ll findnext(ll idx, ll prev) { for (ll i=0; i<ans[idx].size(); i++) if (ans[idx][i]!=prev) return ans[idx][i]; return -1; } void Solve(ll N) { if (N==1) { vector <ll> res; res.pb(1); Answer(res); return; } n=N; for (ll i=1; i<=n; i++) { Find(i, 1, i-1); Find(i, i+1, n); } vector <ll> res; ll st=findstart(); while (st!=-1) { res.pb(st); st=findnext(st, (res.size()==1 ? 0 : res[res.size()-2])); } Answer(res); }

Compilation message (stderr)

library.cpp: In function 'void Find(int, int, int)':
library.cpp:36:21: warning: unused variable 'q' [-Wunused-variable]
   36 |     ll mid=(l+r)/2, q=calc(idx, l, r);
      |                     ^
library.cpp: In function 'int findstart()':
library.cpp:50:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   50 |     for (ll i=1; i<=n; i++)
      |     ^~~
library.cpp:53:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   53 |  return 0;
      |  ^~~~~~
library.cpp: In function 'int findnext(int, int)':
library.cpp:58:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |     for (ll i=0; i<ans[idx].size(); i++)
      |                  ~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...