Submission #47843

# Submission time Handle Problem Language Result Execution time Memory
47843 2018-05-08T06:29:03 Z Just_Solve_The_Problem Library (JOI18_library) C++14
19 / 100
548 ms 544 KB
#include <bits/stdc++.h>
//#include "grader.cpp"
#include "library.h"

#define pb push_back
#define ok cerr << "OK\n";

using namespace std;

const int NN = 1e3 + 7;

bool used[NN];

void Solve(int N) {
	vector < int > M(N, 0);
  vector < int > ans, vv;
  if (N == 1) {
    ans.pb(1);
    Answer(ans);
    return ;
  }
  deque < int > dq;
  int n = N;
  int cnt = 0;

  M[0] = 1;
  dq.pb(0);
  used[0] = 1;
  for (int i = 1; i < n; i++) {
    M[i] = 1;
    int qq = Query(M);
    if (qq == 1) {
      cnt++;
      vv.pb(i);
    }
    M[i] = 0;
  }
  M[0] = 0;
  used[vv[0]] = 1;
  dq.push_front(vv[0]);
  if (cnt == 2) {
    dq.push_back(vv[1]);
    used[vv[1]] = 1;
  }
  vv.clear();
  cnt++;
  while (cnt < n) {
    bool fl = 1;
    M[dq.back()] = 1;
    for (int j = 0; j < n; j++) {
      if (used[j]) continue;
      M[j] = 1;
      int qq = Query(M);
      M[j] = 0;
      if (qq == 1) {
        fl = 0;
        M[dq.back()] = 0;
        dq.pb(j);
        M[j] = 1;
        used[j] = 1;
        cnt++;
        break;
      }
    }
    M[dq.back()] = 0;
    if (fl) break;
  }
  for (int i = 0; i < n; i++) M[i] = 0;
  while (cnt < n) {
    bool fl = 1;
    M[dq.front()] = 1;
    for (int j = 0; j < n; j++) {
      if (used[j]) continue;
      M[j] = 1;
      int qq = Query(M);
      M[j] = 0;
      if (qq == 1) {
        fl = 0;
        M[dq.front()] = 0;
        dq.push_front(j);
        M[dq.front()] = 1;
        used[j] = 1;
        cnt++;
        break;
      }
    }
    if (fl) break;
  }
  for (int to : dq) {
    ans.pb(to + 1);
  }
	Answer(ans);
}
# Verdict Execution time Memory Grader output
1 Correct 129 ms 248 KB Output is correct
2 Correct 149 ms 308 KB Output is correct
3 Correct 186 ms 512 KB Output is correct
4 Correct 96 ms 512 KB Output is correct
5 Correct 183 ms 512 KB Output is correct
6 Correct 175 ms 512 KB Output is correct
7 Correct 150 ms 524 KB Output is correct
8 Correct 157 ms 524 KB Output is correct
9 Correct 161 ms 540 KB Output is correct
10 Correct 60 ms 540 KB Output is correct
11 Correct 2 ms 540 KB Output is correct
12 Correct 2 ms 540 KB Output is correct
13 Correct 2 ms 540 KB Output is correct
14 Correct 2 ms 540 KB Output is correct
15 Correct 4 ms 540 KB Output is correct
16 Correct 4 ms 544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 129 ms 248 KB Output is correct
2 Correct 149 ms 308 KB Output is correct
3 Correct 186 ms 512 KB Output is correct
4 Correct 96 ms 512 KB Output is correct
5 Correct 183 ms 512 KB Output is correct
6 Correct 175 ms 512 KB Output is correct
7 Correct 150 ms 524 KB Output is correct
8 Correct 157 ms 524 KB Output is correct
9 Correct 161 ms 540 KB Output is correct
10 Correct 60 ms 540 KB Output is correct
11 Correct 2 ms 540 KB Output is correct
12 Correct 2 ms 540 KB Output is correct
13 Correct 2 ms 540 KB Output is correct
14 Correct 2 ms 540 KB Output is correct
15 Correct 4 ms 540 KB Output is correct
16 Correct 4 ms 544 KB Output is correct
17 Incorrect 548 ms 544 KB Wrong Answer [3]
18 Halted 0 ms 0 KB -