Submission #47839

# Submission time Handle Problem Language Result Execution time Memory
47839 2018-05-08T06:19:45 Z Just_Solve_The_Problem Library (JOI18_library) C++14
0 / 100
175 ms 672 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;
  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[dq.back()] = 1;
        used[j] = 1;
        cnt++;
        break;
      }
    }
    M[dq.back()] = 0;
    if (fl) break;
  }
  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;
  }
//  cerr << dq.size() << endl;
  for (int to : dq) {
//    cerr << to << ' ';
    ans.pb(to + 1);
  }
	Answer(ans);
}
# Verdict Execution time Memory Grader output
1 Correct 137 ms 288 KB Output is correct
2 Correct 139 ms 436 KB Output is correct
3 Correct 154 ms 436 KB Output is correct
4 Correct 134 ms 436 KB Output is correct
5 Correct 161 ms 436 KB Output is correct
6 Correct 175 ms 436 KB Output is correct
7 Correct 150 ms 504 KB Output is correct
8 Correct 144 ms 504 KB Output is correct
9 Correct 129 ms 504 KB Output is correct
10 Correct 58 ms 532 KB Output is correct
11 Runtime error 2 ms 672 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 137 ms 288 KB Output is correct
2 Correct 139 ms 436 KB Output is correct
3 Correct 154 ms 436 KB Output is correct
4 Correct 134 ms 436 KB Output is correct
5 Correct 161 ms 436 KB Output is correct
6 Correct 175 ms 436 KB Output is correct
7 Correct 150 ms 504 KB Output is correct
8 Correct 144 ms 504 KB Output is correct
9 Correct 129 ms 504 KB Output is correct
10 Correct 58 ms 532 KB Output is correct
11 Runtime error 2 ms 672 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Halted 0 ms 0 KB -