Submission #336709

#TimeUsernameProblemLanguageResultExecution timeMemory
336709mehrdad_sohrabiLibrary (JOI18_library)C++14
19 / 100
454 ms620 KiB
#include <bits/stdc++.h> #include "library.h" typedef int ll; typedef long double ld; #define pb push_back #define pii pair < ll , ll > #define F first #define S second #define endl '\n' //#define int long long #define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0) #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math") #define kill(x) return cout<<x<<'\n', 0; using namespace std; /* ll Query(vector <int> m){ for (int i=0;i<m.size();i++){ cout << m[i] << " "; } cout << endl; ll x; cin >> x; return x; } ll Answer(vector <int> ans){ for (int i=0;i<ans.size();i++){ cout << ans[i] << " "; } cout << endl; } */ ll cnt=0; ll ask(vector <int> a,ll x,ll n){ cnt++; if (cnt==2e4-1) cout << 1/0; vector <int> m; for (int i=0;i<n;i++){ m.pb(0); } for (auto u : a){ m[u-1]=1; } m[x-1]=1; return Query(m); } ll what(ll x,ll y,ll n){ cnt++; if (cnt==2e4-1) cout << 1/0; vector <int> m; for (int i=0;i<n;i++){ m.pb(0); } m[y-1]=1; m[x-1]=1; return Query(m); } void Solve(ll n){ vector <vector <int> > mol; ll cnt=1; vector <int> a; for (int i=1;i<=n;i++){ a.pb(i); } random_shuffle(a.begin(),a.end()); for (auto u : a){ if (mol.size()==0){ vector <int> t; t.pb(u); mol.pb(t); continue; } vector <int> t; for (auto z : mol){ for (auto v : z){ t.pb(v); } } ll w=ask(t,u,n); //cout << cnt << " " << w << endl; if (w>cnt){ cnt=w; vector <int> d; d.pb(u); mol.pb(d); continue; } vector <int> q; ll p1=0; vector <vector <int> > lom; for (int i=0;i<mol.size();i++){ vector <int> v=mol[i]; if (v.size()==0){ cout << 1/0; } ll w=ask(v,u,n); if (w>1) { lom.pb(v); continue; } if (p1==0){ if (what(mol[i].back(),u,n)==1){ q=mol[i]; q.pb(u); } else{ reverse(mol[i].begin(),mol[i].end()); q=mol[i]; q.pb(u); } p1=1; } else { p1=2; if (what(mol[i][0],u,n)==1){ for (auto z : mol[i]){ q.pb(z); } } else{ reverse(mol[i].begin(),mol[i].end()); for (auto z : mol[i]){ q.pb(z); } } } if (p1==2 || (p1==1 && cnt==w)) { for (int j=i+1;j<mol.size();j++){ lom.pb(mol[j]); } break; } } cnt=w; mol=lom; mol.pb(q); } if (mol.size()>1){ // cout << "KIR KHAR" << endl; } Answer(mol[0]); } /* int32_t main(){ ll n; cin >> n; Solve(n); } */

Compilation message (stderr)

library.cpp: In function 'll ask(std::vector<int>, ll, ll)':
library.cpp:35:30: warning: division by zero [-Wdiv-by-zero]
   35 |     if (cnt==2e4-1) cout << 1/0;
      |                             ~^~
library.cpp: In function 'll what(ll, ll, ll)':
library.cpp:48:30: warning: division by zero [-Wdiv-by-zero]
   48 |     if (cnt==2e4-1) cout << 1/0;
      |                             ~^~
library.cpp: In function 'void Solve(ll)':
library.cpp:90:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   90 |         for (int i=0;i<mol.size();i++){
      |                      ~^~~~~~~~~~~
library.cpp:93:26: warning: division by zero [-Wdiv-by-zero]
   93 |                 cout << 1/0;
      |                         ~^~
library.cpp:128:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  128 |                 for (int j=i+1;j<mol.size();j++){
      |                                ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...