답안 #202407

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
202407 2020-02-16T03:55:07 Z EntityIT 도서관 (JOI18_library) C++14
0 / 100
648 ms 262148 KB
#include "library.h"
#include<bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define sz(x) ( (int)(x).size() )
using LL = long long;

void Solve(int N) {
  vector<int> pref(N);
  vector<int> ele(N);
  for (int i = 0; i < N; ++i) {
    fill(all(ele), 0);
    fill(ele.begin(), ele.begin() + i + 1, 1);
    pref[i] = Query(ele);
  }

  vector<vector<int> > gr(N);
  for (int i = 1; i < N; ++i) if (pref[i] ^ pref[i - 1]) {
    int l = 0, r = i - 1;
    while (l < r) {
      int mid = (l + r) >> 1;
      fill(all(ele), 0);
      fill(ele.begin(), ele.begin() + mid + 1, 1);
      ele[i] = 1;
      if (Query(ele) != pref[mid]) r = mid;
      else l = mid + 1;
    }

    gr[i].emplace_back(l);
    gr[l].emplace_back(i);

    if (pref[i] - pref[i - 1] > 1) {
      l = 0, r = i - 1;
      while (l < r) {
        int mid = (l + r) >> 1;
        fill(all(ele), 0);
        fill(ele.begin(), ele.begin() + mid + 1, 1);
        ele[i] = 1;
        if (Query(ele) - pref[mid] > 1) r = mid;
        else l = mid + 1;
      }

      gr[i].emplace_back(l);
      gr[l].emplace_back(i);
    }
  }

  int rt = -1;
  for (int u = 0; u < N; ++u) if (sz(gr[u]) == 1) rt = u;

  vector<bool> vis(N);
  vector<int> ans;
  for (int u = rt; ; ) {
    vis[u] = true;
    ans.emplace_back(u);
    for (int v : gr[u]) if (!vis[v]) u = v;
  }

  Answer(ans);
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 508 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Runtime error 476 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Runtime error 462 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Runtime error 489 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
5 Runtime error 466 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Runtime error 479 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Runtime error 455 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 460 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Runtime error 460 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 448 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
11 Runtime error 5 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 5 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 5 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 445 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
15 Runtime error 486 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
16 Runtime error 448 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 508 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Runtime error 476 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Runtime error 462 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Runtime error 489 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
5 Runtime error 466 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Runtime error 479 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Runtime error 455 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 460 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Runtime error 460 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 448 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
11 Runtime error 5 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 5 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 5 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 445 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
15 Runtime error 486 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
16 Runtime error 448 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
17 Runtime error 626 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
18 Runtime error 648 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
19 Runtime error 627 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
20 Runtime error 622 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
21 Runtime error 584 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
22 Runtime error 619 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
23 Runtime error 609 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
24 Runtime error 506 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
25 Runtime error 621 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
26 Runtime error 597 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
27 Runtime error 504 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
28 Runtime error 39 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
29 Runtime error 31 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
30 Runtime error 35 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)