답안 #896828

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
896828 2024-01-02T09:14:14 Z NeroZein Meetings (JOI19_meetings) C++17
100 / 100
576 ms 1248 KB
#include "meetings.h"
#include <bits/stdc++.h>

using namespace std; 

int crt;

bool cmp(int i, int j) {
  //cout << "crt: " << crt << ' ' << i << ' ' << j << endl;
  return (Query(crt, i, j) == i);
}

void rec(int root, vector<int>& vec) {
  if (vec.empty()) return; 
  crt = root;
  map<int, vector<int>> newvec; 
  int v = vec[rand() % vec.size()];
  //cout << "O: " << root << ' ' << v << endl;
  vector<int> onpath = {root, v};
  for (int u : vec) {
    if (u != v) {
      int q = Query(root, v, u);
      if (q == u) {
        onpath.push_back(u);
        //cout << "U: " << u << endl;
      } else {
        newvec[q].push_back(u);
      }
    }
  }
  //cout << endl; 
  sort(onpath.begin() + 1, onpath.end(), cmp);
  //cout << "ONPATH: ";
  //for (int i : onpath) cout << i << ' ';
  //cout << endl; 
  for (int i = 1; i < (int) onpath.size(); ++i) {
    int x = onpath[i - 1], y = onpath[i];
    if (x > y) swap(x, y);
    //cout << x << ' ' << y << endl; 
    Bridge(x, y);
  }
  for (int u : onpath) {
    rec(u, newvec[u]); 
  }
}

void Solve(int N) {
  int root = rand() % N;
  vector<int> vec;
  for (int i = 0; i < N; ++i) {
    if (i != root) {
      vec.push_back(i);
    }
  }
  rec(root, vec); 
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 508 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 1 ms 484 KB Output is correct
25 Correct 0 ms 344 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 508 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 1 ms 484 KB Output is correct
25 Correct 0 ms 344 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 8 ms 344 KB Output is correct
28 Correct 5 ms 508 KB Output is correct
29 Correct 3 ms 344 KB Output is correct
30 Correct 6 ms 344 KB Output is correct
31 Correct 3 ms 508 KB Output is correct
32 Correct 6 ms 344 KB Output is correct
33 Correct 13 ms 344 KB Output is correct
34 Correct 9 ms 344 KB Output is correct
35 Correct 9 ms 540 KB Output is correct
36 Correct 4 ms 524 KB Output is correct
37 Correct 7 ms 524 KB Output is correct
38 Correct 10 ms 344 KB Output is correct
39 Correct 5 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 241 ms 680 KB Output is correct
2 Correct 238 ms 852 KB Output is correct
3 Correct 291 ms 752 KB Output is correct
4 Correct 248 ms 656 KB Output is correct
5 Correct 195 ms 652 KB Output is correct
6 Correct 172 ms 724 KB Output is correct
7 Correct 365 ms 856 KB Output is correct
8 Correct 429 ms 756 KB Output is correct
9 Correct 432 ms 724 KB Output is correct
10 Correct 408 ms 768 KB Output is correct
11 Correct 496 ms 600 KB Output is correct
12 Correct 292 ms 828 KB Output is correct
13 Correct 124 ms 600 KB Output is correct
14 Correct 267 ms 740 KB Output is correct
15 Correct 249 ms 1124 KB Output is correct
16 Correct 239 ms 688 KB Output is correct
17 Correct 408 ms 680 KB Output is correct
18 Correct 228 ms 668 KB Output is correct
19 Correct 236 ms 748 KB Output is correct
20 Correct 307 ms 1248 KB Output is correct
21 Correct 311 ms 688 KB Output is correct
22 Correct 256 ms 1104 KB Output is correct
23 Correct 256 ms 600 KB Output is correct
24 Correct 238 ms 672 KB Output is correct
25 Correct 245 ms 1128 KB Output is correct
26 Correct 222 ms 768 KB Output is correct
27 Correct 251 ms 740 KB Output is correct
28 Correct 490 ms 916 KB Output is correct
29 Correct 395 ms 780 KB Output is correct
30 Correct 419 ms 600 KB Output is correct
31 Correct 479 ms 848 KB Output is correct
32 Correct 576 ms 848 KB Output is correct
33 Correct 344 ms 856 KB Output is correct
34 Correct 5 ms 344 KB Output is correct
35 Correct 3 ms 344 KB Output is correct
36 Correct 4 ms 344 KB Output is correct
37 Correct 4 ms 344 KB Output is correct
38 Correct 3 ms 344 KB Output is correct
39 Correct 4 ms 344 KB Output is correct
40 Correct 7 ms 344 KB Output is correct
41 Correct 9 ms 596 KB Output is correct
42 Correct 9 ms 520 KB Output is correct
43 Correct 4 ms 344 KB Output is correct
44 Correct 7 ms 344 KB Output is correct
45 Correct 10 ms 344 KB Output is correct
46 Correct 5 ms 344 KB Output is correct
47 Correct 0 ms 344 KB Output is correct
48 Correct 0 ms 344 KB Output is correct
49 Correct 0 ms 344 KB Output is correct
50 Correct 0 ms 344 KB Output is correct
51 Correct 0 ms 344 KB Output is correct
52 Correct 0 ms 344 KB Output is correct
53 Correct 1 ms 596 KB Output is correct
54 Correct 0 ms 344 KB Output is correct
55 Correct 0 ms 344 KB Output is correct
56 Correct 0 ms 480 KB Output is correct
57 Correct 1 ms 344 KB Output is correct
58 Correct 0 ms 344 KB Output is correct
59 Correct 0 ms 344 KB Output is correct
60 Correct 0 ms 344 KB Output is correct
61 Correct 0 ms 344 KB Output is correct
62 Correct 1 ms 600 KB Output is correct
63 Correct 0 ms 344 KB Output is correct
64 Correct 0 ms 344 KB Output is correct
65 Correct 0 ms 344 KB Output is correct
66 Correct 0 ms 344 KB Output is correct
67 Correct 0 ms 460 KB Output is correct
68 Correct 0 ms 344 KB Output is correct
69 Correct 0 ms 344 KB Output is correct
70 Correct 0 ms 344 KB Output is correct
71 Correct 0 ms 344 KB Output is correct
72 Correct 0 ms 344 KB Output is correct