Submission #47845

# Submission time Handle Problem Language Result Execution time Memory
47845 2018-05-08T06:33:25 Z mirbek01 Library (JOI18_library) C++17
19 / 100
451 ms 588 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){
                        cn ++;
                        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){
                    	cn ++;
                        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 Correct 144 ms 248 KB Output is correct
2 Correct 122 ms 436 KB Output is correct
3 Correct 132 ms 436 KB Output is correct
4 Correct 144 ms 564 KB Output is correct
5 Correct 162 ms 564 KB Output is correct
6 Correct 178 ms 564 KB Output is correct
7 Correct 137 ms 564 KB Output is correct
8 Correct 147 ms 580 KB Output is correct
9 Correct 132 ms 580 KB Output is correct
10 Correct 58 ms 580 KB Output is correct
11 Correct 1 ms 580 KB Output is correct
12 Correct 2 ms 580 KB Output is correct
13 Correct 2 ms 580 KB Output is correct
14 Correct 2 ms 580 KB Output is correct
15 Correct 2 ms 580 KB Output is correct
16 Correct 4 ms 580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 144 ms 248 KB Output is correct
2 Correct 122 ms 436 KB Output is correct
3 Correct 132 ms 436 KB Output is correct
4 Correct 144 ms 564 KB Output is correct
5 Correct 162 ms 564 KB Output is correct
6 Correct 178 ms 564 KB Output is correct
7 Correct 137 ms 564 KB Output is correct
8 Correct 147 ms 580 KB Output is correct
9 Correct 132 ms 580 KB Output is correct
10 Correct 58 ms 580 KB Output is correct
11 Correct 1 ms 580 KB Output is correct
12 Correct 2 ms 580 KB Output is correct
13 Correct 2 ms 580 KB Output is correct
14 Correct 2 ms 580 KB Output is correct
15 Correct 2 ms 580 KB Output is correct
16 Correct 4 ms 580 KB Output is correct
17 Incorrect 451 ms 588 KB Wrong Answer [3]
18 Halted 0 ms 0 KB -