답안 #837954

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
837954 2023-08-25T21:26:09 Z taher 드문 곤충 (IOI22_insects) C++17
10 / 100
236 ms 336 KB
#include "insects.h"
#include <bits/stdc++.h>

using namespace std;

class dsu {
  public:
  int n;
  vector<int> par;
  vector<int> size;
  
  dsu(int _n) : n(_n) {
    par.resize(n);
    iota(par.begin(), par.end(), 0);
    size.resize(n);
    for (int i = 0; i < n; i++) {
      size[i] = 1; 
    }
  }
  
  int get(int x) {
    if (par[x] == x) {
      return par[x];
    }
    return par[x] = get(par[x]); 
  }
  
  bool unite(int x, int y) {
    x = get(x);
    y = get(y);
    
    if (x == y) {
      return false; 
    }
    par[x] = y;
    size[y] += size[x];
    return true; 
  }
};

int min_cardinality(int N) {

  int n = N;
  
  dsu ds(n);

  for (int i = 0; i < n; i++) {
    move_inside(i);
    for (int j = i + 1; j < n; j++) {
      move_inside(j);
      
      if (press_button() == 2) {
        ds.unite(i, j); 
      }
      move_outside(j);
    }
    move_outside(i);
  }
  
  int res = 123456;
  
  for (int i = 0; i < n; i++) {
    if (ds.get(i) == i) {
      res = min(res, ds.size[i]); 
    }
  }
  return res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 125 ms 208 KB Output is correct
7 Correct 71 ms 208 KB Output is correct
8 Correct 131 ms 208 KB Output is correct
9 Correct 93 ms 208 KB Output is correct
10 Correct 104 ms 208 KB Output is correct
11 Correct 93 ms 208 KB Output is correct
12 Correct 112 ms 208 KB Output is correct
13 Correct 128 ms 208 KB Output is correct
14 Correct 118 ms 208 KB Output is correct
15 Correct 128 ms 208 KB Output is correct
16 Correct 95 ms 208 KB Output is correct
17 Correct 79 ms 208 KB Output is correct
18 Correct 124 ms 208 KB Output is correct
19 Correct 78 ms 208 KB Output is correct
20 Correct 116 ms 208 KB Output is correct
21 Correct 80 ms 336 KB Output is correct
22 Correct 125 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 125 ms 208 KB Output is correct
7 Correct 71 ms 208 KB Output is correct
8 Correct 131 ms 208 KB Output is correct
9 Correct 93 ms 208 KB Output is correct
10 Correct 104 ms 208 KB Output is correct
11 Correct 93 ms 208 KB Output is correct
12 Correct 112 ms 208 KB Output is correct
13 Correct 128 ms 208 KB Output is correct
14 Correct 118 ms 208 KB Output is correct
15 Correct 128 ms 208 KB Output is correct
16 Correct 95 ms 208 KB Output is correct
17 Correct 79 ms 208 KB Output is correct
18 Correct 124 ms 208 KB Output is correct
19 Correct 78 ms 208 KB Output is correct
20 Correct 116 ms 208 KB Output is correct
21 Correct 80 ms 336 KB Output is correct
22 Correct 125 ms 208 KB Output is correct
23 Incorrect 210 ms 208 KB Too many queries.
24 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Partially correct 0 ms 208 KB Output is partially correct
6 Partially correct 0 ms 208 KB Output is partially correct
7 Incorrect 236 ms 312 KB Too many queries.
8 Halted 0 ms 0 KB -