Submission #47840

# Submission time Handle Problem Language Result Execution time Memory
47840 2018-05-08T06:20:20 Z mirbek01 Library (JOI18_library) C++17
0 / 100
5 ms 248 KB
#include <cstdio>
#include <vector>
#include "library.h"
using namespace std;

void Solve(int N){
      vector <int> res(N), M(N), used(N), a(N), b(N);

      int cur = 0, p1 = 0;
      a[0] = 0;
      b[0] = 0;
      used[0] = 1;

      while(1){
            int cn = 0;
            for(int i = 0; i < N; i ++){
                  if(used[i]) continue;
                  M[cur] = 1;
                  M[i] = 1;
                  int re = Query(M);
                  M[cur] = 0;
                  M[i] = 0;
                  if(re == 1){
                        used[i] = 1;
                        a[++ p1] = i;
                        cur = i;
                        break;
                  }
            }
            if(!cn) break;
      }
      cur = 0;
      int p2 = 0;
      while(1){
            int cn = 0;
            for(int i = 0; i < N; i ++){
                  if(used[i]) continue;
                  M[cur] = 1;
                  M[i] = 1;
                  int re = Query(M);
                  M[cur] = 0;
                  M[i] = 0;
                  if(re == 1){
                        used[i] = 1;
                        b[++ p2] = i;
                        cur = i;
                        break;
                  }
            }
            if(!cn) break;
      }
      int ps = 0;
      for(int i = p2; i > 0; i --){
            res[ps ++] = b[i] + 1;
      }
      for(int i = 0; i < p1; i ++){
            res[ps ++] = a[i] + 1;
      }

	Answer(res);
}
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 248 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 248 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -