Submission #436178

#TimeUsernameProblemLanguageResultExecution timeMemory
436178HediChehaidarLibrary (JOI18_library)C++17
19 / 100
415 ms356 KiB
/* ID: hedichehaidar TASK: photo LANG: C++11 */ #include<bits/stdc++.h> #include "library.h" typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef double db; ll gcd(ll a , ll b) {return b ? gcd(b , a % b) : a ;} // greatest common divisor (PGCD) ll lcm(ll a , ll b) {return (a * b) / gcd(a , b);} // least common multiple (PPCM) #define ss second #define ff first #define all(x) (x).begin() , (x).end() #define pb push_back #define vi vector<int> #define vii vector<pair<int,int>> #define vl vector<ll> #define vll vector<pair<ll,ll>> #define pii pair<int,int> #define pll pair<ll,ll> #define pdd pair<double,double> #define vdd vector<pdd> #define dte tuple<double , double , double> using namespace std; const int INF = 1000*1000*1000; // 1 e 9 const int MOD = INF + 7; const double EPS = 0.000000001; // 1 e -9 const ll inf = (ll)1e18; int n; bool seen[1010]; /*int Query(vi v){ for(auto c : v) cout << c << " "; cout << endl; int x; cin>>x; return x; } void Answer(vi v){ for(auto c : v) cout << c << " "; cout << endl; }*/ void Solve(int N){ n = N; vi ask(n , 0); vi ans; deque<int> dq; dq.pb(1); ask[0] = 1; seen[1] = true; while(dq.size() < n){ for(int i = 1 ; i <= n ; i++){ if(!seen[i]){ ask[i - 1] = 1; if(Query(ask) == 1){ if(dq.size() == 1) dq.pb(i); else{ vi v(n , 0); v[dq.front() - 1] = 1; v[i - 1] = 1; if(Query(v) == 1) dq.push_front(i); else dq.pb(i); } seen[i] = true; break; } ask[i - 1] = 0; } } } for(auto c : dq){ ans.pb(c); } Answer(ans); } /*int main(){ //ifstream fin ("race.in"); //ofstream fout ("race.out"); ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); int N; cin>>N; Solve(N); return 0; }*/ /* Think of : BS / DFS / BFS / SSSP / SCC / MSP / MAX FLOW / TOPSORT / LCA / MATRIX / DP(bitmask) / 2 POINTERS / SEG TREE / MATH / UN FIND / MO Read the statement CAREFULLY !! Make a GREADY APPROACH !!!! (start from highest / lowest) Make your own TESTS !! Be careful from CORNER CASES ! */

Compilation message (stderr)

library.cpp: In function 'void Solve(int)':
library.cpp:50:21: warning: comparison of integer expressions of different signedness: 'std::deque<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   50 |     while(dq.size() < n){
      |           ~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...