Submission #48070

#TimeUsernameProblemLanguageResultExecution timeMemory
48070kawaiigrabrielnekoLibrary (JOI18_library)C++14
0 / 100
34 ms300 KiB
#include <cstdio> #include <vector> #include "library.h" using namespace std; void Solve(int N){ vector<int> A(N); vector<int> B(N); vector<int> AP(N); vector<int> AMB(N); vector<int> APUB(N); int na = N/2; vector<int> ans(N); for (int i = 0; i < N/2; i++){ A[i] = 1; AP[i] = 0; } for (int i = N/2; i < N; i++){ A[i] = 0; AP[i] = 1; } if (Query(A)<Query(AP)){ for (int i = 0; i < N; i++){ A[i] = 1 - A[i]; AP[i] = 1 - AP[i]; } na = N - na; } while (na > 1){ int nb = na/2; int ct = 0; for (int i = 0; i < N; i++){ if (A[i]==1&&ct<nb){ B[i] = 1; ct++; } else B[i] = 0; AMB[i] = A[i] - B[i]; APUB[i] = 1 - AMB[i]; } if (Query(AMB)<Query(APUB)){ // Endpoint in B for (int i = 0; i < N; i++){ A[i] = B[i]; } na = nb; } else { // Endpoint in A - B for (int i = 0; i < N; i++){ AMB[i] = B[i]; } na = na - nb; } } for (int i = 0; i < N; i++){ if (A[i] == 1) ans[0] = i; } vector<int> M(N); vector<int> K(N); for (int i = 1; i < N; i++){ int nm = N-i; int ct = 0; for (int j = 0; j < N; j++){ M[j] = 1; } for (int j = 0; j < i; j++){ M[ans[j]] = 0; } while (nm > 1){ int nk = nm/2; int ct = 0; for (int j = 0; j < N; j++){ if (M[j]==1&&ct<nk){ ct++; K[j] = 1; } else K[j] = 0; } int x = Query(K); K[ans[i-1]] = 1; if (x==Query(K)){ K[ans[i-1]] = 0; nm = nk; for (int j = 0; j < N; j++){ M[j] = K[j]; } } else { K[ans[i-1]] = 0; nm = nm - nk; for (int j = 0; j < N; j++){ M[j] = M[j] - K[j]; } } } for (int j = 0; j < N; j++){ if (M[j]==1) ans[i] = j; } } for (int i = 0; i < N; i++){ ans[i]++; } Answer(ans); }

Compilation message (stderr)

library.cpp: In function 'void Solve(int)':
library.cpp:61:13: warning: unused variable 'ct' [-Wunused-variable]
         int ct = 0;
             ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...