답안 #1099926

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1099926 2024-10-12T05:53:02 Z model_code 스핑크스 (IOI24_sphinx) C++17
50 / 100
249 ms 1188 KB
// partially_correct/BM-partial.cpp

#include <set>

#include "sphinx.h"

using namespace std;

int N;
int p[250];
vector<int> edge[250];
vector<int> ord;
bool reached[250];
set<int> unchecked;
bool keep[250];

int where(int x) {
  if (p[x] < 0) return x;
  return (p[x] = where(p[x]));
}

int color(int x) { return (ord[x] >= 0 ? ord[x] : where(x)); }

void dfs(int x) {
  reached[x] = true;
  for (int i : edge[x]) {
    if (!reached[i] && color(x) == color(i)) dfs(i);
  }
}

int expected() {
  for (int i = 0; i < N; i++) reached[i] = false;

  int sum = 0;
  for (int i = 0; i < N; i++) {
    if (!reached[i]) {
      sum++;
      dfs(i);
    }
  }

  return sum;
}

vector<int> find_colours(int NN, vector<int> X, vector<int> Y) {
  N = NN;
  ord.resize(N);
  for (int i = 0; i < N; i++) p[i] = -1;

  int M = X.size();
  for (int i = 0; i < M; i++) {
    edge[Y[i]].push_back(X[i]);
    edge[X[i]].push_back(Y[i]);
  }

  for (int i = 1; i < N; i++) {
    while (true) {
      for (int j = 0; j <= i; j++) ord[j] = -1;
      for (int j = i + 1; j < N; j++) ord[j] = N;
      if (perform_experiment(ord) == expected()) break;

      unchecked.clear();
      for (int j = 0; j < i; j++) {
        if (where(j) != i) unchecked.insert(where(j));
      }

      vector<int> vec(unchecked.size());
      int pos = 0;
      for (int j : unchecked) vec[pos++] = j;

      int a = 0, b = pos - 1;
      while (a != b) {
        int half = (a + b) / 2;
        for (int j = 0; j < N; j++) keep[j] = false;
        for (int j = a; j <= half; j++) keep[vec[j]] = true;
        for (int j = 0; j < i; j++) {
          if (keep[where(j)]) {
            ord[j] = -1;
          } else {
            ord[j] = N;
          }
        }
        ord[i] = -1;
        for (int j = i + 1; j < N; j++) ord[j] = N;

        if (perform_experiment(ord) == expected()) {
          a = half + 1;
        } else {
          b = half;
        }
      }
      p[where(vec[a])] = i;
    }
  }

  vector<int> F(N);
  for (int i = 0; i < N; i++) F[i] = where(i);
  return F;
}
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 344 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 344 KB Partially correct
2 Correct 0 ms 344 KB #experiments: 1
3 Partially correct 0 ms 344 KB Partially correct
4 Correct 0 ms 344 KB #experiments: 2
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 344 KB Partially correct
2 Partially correct 0 ms 344 KB Partially correct
3 Correct 0 ms 344 KB #experiments: 1
4 Partially correct 0 ms 344 KB Partially correct
5 Correct 0 ms 344 KB #experiments: 2
6 Partially correct 2 ms 344 KB Partially correct
7 Partially correct 3 ms 344 KB Partially correct
8 Partially correct 3 ms 596 KB Partially correct
9 Partially correct 3 ms 344 KB Partially correct
10 Partially correct 2 ms 344 KB Partially correct
11 Partially correct 2 ms 344 KB Partially correct
12 Partially correct 1 ms 344 KB Partially correct
13 Partially correct 1 ms 344 KB Partially correct
14 Partially correct 1 ms 344 KB Partially correct
15 Partially correct 5 ms 344 KB Partially correct
16 Partially correct 4 ms 344 KB Partially correct
17 Partially correct 5 ms 344 KB Partially correct
18 Partially correct 3 ms 344 KB Partially correct
19 Partially correct 4 ms 344 KB Partially correct
20 Partially correct 3 ms 344 KB Partially correct
21 Partially correct 1 ms 344 KB Partially correct
22 Partially correct 2 ms 344 KB Partially correct
23 Partially correct 1 ms 344 KB Partially correct
24 Partially correct 1 ms 344 KB Partially correct
25 Partially correct 1 ms 344 KB Partially correct
26 Partially correct 1 ms 344 KB Partially correct
27 Partially correct 1 ms 344 KB Partially correct
28 Partially correct 1 ms 344 KB Partially correct
29 Partially correct 2 ms 344 KB Partially correct
30 Partially correct 1 ms 344 KB Partially correct
31 Partially correct 4 ms 344 KB Partially correct
32 Partially correct 4 ms 344 KB Partially correct
33 Partially correct 2 ms 344 KB Partially correct
34 Partially correct 1 ms 344 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 344 KB Partially correct
2 Correct 0 ms 344 KB #experiments: 1
3 Partially correct 0 ms 344 KB Partially correct
4 Correct 0 ms 344 KB #experiments: 2
5 Partially correct 2 ms 344 KB Partially correct
6 Partially correct 3 ms 344 KB Partially correct
7 Partially correct 3 ms 596 KB Partially correct
8 Partially correct 3 ms 344 KB Partially correct
9 Partially correct 2 ms 344 KB Partially correct
10 Partially correct 2 ms 344 KB Partially correct
11 Partially correct 1 ms 344 KB Partially correct
12 Partially correct 1 ms 344 KB Partially correct
13 Partially correct 13 ms 344 KB Partially correct
14 Partially correct 19 ms 344 KB Partially correct
15 Partially correct 23 ms 460 KB Partially correct
16 Partially correct 28 ms 464 KB Partially correct
17 Partially correct 28 ms 460 KB Partially correct
18 Partially correct 24 ms 448 KB Partially correct
19 Partially correct 15 ms 716 KB Partially correct
20 Partially correct 16 ms 344 KB Partially correct
21 Partially correct 7 ms 344 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 344 KB Partially correct
2 Correct 0 ms 344 KB #experiments: 1
3 Partially correct 0 ms 344 KB Partially correct
4 Correct 0 ms 344 KB #experiments: 2
5 Partially correct 1 ms 344 KB Partially correct
6 Partially correct 5 ms 344 KB Partially correct
7 Partially correct 4 ms 344 KB Partially correct
8 Partially correct 5 ms 344 KB Partially correct
9 Partially correct 3 ms 344 KB Partially correct
10 Partially correct 4 ms 344 KB Partially correct
11 Partially correct 3 ms 344 KB Partially correct
12 Partially correct 1 ms 344 KB Partially correct
13 Partially correct 116 ms 1180 KB Partially correct
14 Partially correct 189 ms 1180 KB Partially correct
15 Partially correct 186 ms 1112 KB Partially correct
16 Partially correct 218 ms 1180 KB Partially correct
17 Partially correct 249 ms 1180 KB Partially correct
18 Partially correct 179 ms 1188 KB Partially correct
19 Partially correct 171 ms 1184 KB Partially correct
20 Partially correct 61 ms 1112 KB Partially correct
21 Partially correct 54 ms 1112 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 344 KB Partially correct
2 Partially correct 0 ms 344 KB Partially correct
3 Correct 0 ms 344 KB #experiments: 1
4 Partially correct 0 ms 344 KB Partially correct
5 Correct 0 ms 344 KB #experiments: 2
6 Partially correct 2 ms 344 KB Partially correct
7 Partially correct 3 ms 344 KB Partially correct
8 Partially correct 3 ms 596 KB Partially correct
9 Partially correct 3 ms 344 KB Partially correct
10 Partially correct 2 ms 344 KB Partially correct
11 Partially correct 2 ms 344 KB Partially correct
12 Partially correct 1 ms 344 KB Partially correct
13 Partially correct 1 ms 344 KB Partially correct
14 Partially correct 1 ms 344 KB Partially correct
15 Partially correct 5 ms 344 KB Partially correct
16 Partially correct 4 ms 344 KB Partially correct
17 Partially correct 5 ms 344 KB Partially correct
18 Partially correct 3 ms 344 KB Partially correct
19 Partially correct 4 ms 344 KB Partially correct
20 Partially correct 3 ms 344 KB Partially correct
21 Partially correct 1 ms 344 KB Partially correct
22 Partially correct 2 ms 344 KB Partially correct
23 Partially correct 1 ms 344 KB Partially correct
24 Partially correct 1 ms 344 KB Partially correct
25 Partially correct 1 ms 344 KB Partially correct
26 Partially correct 1 ms 344 KB Partially correct
27 Partially correct 1 ms 344 KB Partially correct
28 Partially correct 1 ms 344 KB Partially correct
29 Partially correct 2 ms 344 KB Partially correct
30 Partially correct 1 ms 344 KB Partially correct
31 Partially correct 4 ms 344 KB Partially correct
32 Partially correct 4 ms 344 KB Partially correct
33 Partially correct 2 ms 344 KB Partially correct
34 Partially correct 1 ms 344 KB Partially correct
35 Partially correct 13 ms 344 KB Partially correct
36 Partially correct 19 ms 344 KB Partially correct
37 Partially correct 23 ms 460 KB Partially correct
38 Partially correct 28 ms 464 KB Partially correct
39 Partially correct 28 ms 460 KB Partially correct
40 Partially correct 24 ms 448 KB Partially correct
41 Partially correct 15 ms 716 KB Partially correct
42 Partially correct 16 ms 344 KB Partially correct
43 Partially correct 7 ms 344 KB Partially correct
44 Partially correct 116 ms 1180 KB Partially correct
45 Partially correct 189 ms 1180 KB Partially correct
46 Partially correct 186 ms 1112 KB Partially correct
47 Partially correct 218 ms 1180 KB Partially correct
48 Partially correct 249 ms 1180 KB Partially correct
49 Partially correct 179 ms 1188 KB Partially correct
50 Partially correct 171 ms 1184 KB Partially correct
51 Partially correct 61 ms 1112 KB Partially correct
52 Partially correct 54 ms 1112 KB Partially correct
53 Partially correct 44 ms 484 KB Partially correct
54 Partially correct 71 ms 344 KB Partially correct
55 Partially correct 73 ms 552 KB Partially correct
56 Partially correct 84 ms 344 KB Partially correct
57 Partially correct 30 ms 600 KB Partially correct
58 Partially correct 22 ms 600 KB Partially correct
59 Partially correct 25 ms 768 KB Partially correct
60 Partially correct 17 ms 600 KB Partially correct
61 Partially correct 19 ms 464 KB Partially correct
62 Partially correct 11 ms 600 KB Partially correct
63 Partially correct 5 ms 344 KB Partially correct
64 Partially correct 81 ms 344 KB Partially correct
65 Partially correct 65 ms 344 KB Partially correct
66 Partially correct 72 ms 344 KB Partially correct
67 Partially correct 66 ms 344 KB Partially correct
68 Partially correct 78 ms 344 KB Partially correct
69 Partially correct 65 ms 344 KB Partially correct
70 Partially correct 73 ms 560 KB Partially correct
71 Partially correct 79 ms 344 KB Partially correct
72 Partially correct 27 ms 344 KB Partially correct
73 Partially correct 54 ms 500 KB Partially correct
74 Partially correct 45 ms 528 KB Partially correct
75 Partially correct 73 ms 344 KB Partially correct
76 Partially correct 77 ms 344 KB Partially correct
77 Partially correct 88 ms 344 KB Partially correct
78 Partially correct 75 ms 344 KB Partially correct
79 Partially correct 105 ms 344 KB Partially correct
80 Partially correct 67 ms 340 KB Partially correct
81 Partially correct 94 ms 344 KB Partially correct
82 Partially correct 35 ms 600 KB Partially correct
83 Partially correct 201 ms 856 KB Partially correct
84 Partially correct 149 ms 1112 KB Partially correct
85 Partially correct 23 ms 600 KB Partially correct
86 Partially correct 19 ms 600 KB Partially correct