Submission #47838

#TimeUsernameProblemLanguageResultExecution timeMemory
47838InovakLibrary (JOI18_library)C++14
19 / 100
554 ms580 KiB
#include <bits/stdc++.h> #include "library.h" //#include "grader.cpp" #define fr first #define sc second #define pb push_back #define mk make_pair #define ll long long #define OK puts("OK") #define sz(s) (int)s.size() #define all(s) s.begin(), s.end() using namespace std; bool u[3000]; void Solve(int n) { vector<int> M(n); deque <int> dq; dq.pb(1); u[0] = 1; M[0] = 1; int ans = -1, anb = -1; for(int i = 0; i < n; i++) { if(u[i]) continue; M[i] = 1; int A = Query(M); if(A == 1 && ans == -1) ans = i; else if(A == 1) anb = i; M[i] = 0; } M[0] = 0; if(n > 1) { u[ans] = 1; dq.pb(ans + 1); } while(dq.size() < n) { M[ans] = 1; int an = -1; for(int i = 0; i < n; i++) { if(u[i]) continue; M[i] = 1; int A = Query(M); M[i] = 0; if(A == 1) an = i; } M[ans] = 0; if(an == -1) break; u[an] = 1; ans = an; dq.pb(ans + 1); } if(dq.size() < n) { ans = anb; u[ans] = 1; dq.push_front(ans + 1); while(dq.size() < n) { M[ans] = 1; int an = -1; for(int i = 0; i < n; i++) { if(u[i]) continue; M[i] = 1; int A = Query(M); M[i] = 0; if(A == 1) an = i; } M[ans] = 0; if(an == -1) break; u[an] = 1; ans = an; dq.push_front(ans + 1); } } vector <int> res; while(!dq.empty()) res.pb(dq.front()), dq.pop_front(); Answer(res); } /** 5 4 2 5 3 1 **/

Compilation message (stderr)

library.cpp: In function 'void Solve(int)':
library.cpp:41:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(dq.size() < n) {
           ~~~~~~~~~~^~~
library.cpp:57:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(dq.size() < n) {
        ~~~~~~~~~~^~~
library.cpp:62:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while(dq.size() < n) {
               ~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...