Submission #336699

#TimeUsernameProblemLanguageResultExecution timeMemory
336699mehrdad_sohrabiLibrary (JOI18_library)C++14
0 / 100
7 ms364 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 ask(vector <int> a,ll x,ll n){ 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){ 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){ // cout << u << endl; } 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); if (w>cnt){ 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]; 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 { 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); } } } } 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 'void Solve(ll)':
library.cpp:60:15: warning: unused variable 'u' [-Wunused-variable]
   60 |     for (auto u : a){
      |               ^
library.cpp:86:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   86 |         for (int i=0;i<mol.size();i++){
      |                      ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...