답안 #1042409

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1042409 2024-08-03T03:59:16 Z Alihan_8 드문 곤충 (IOI22_insects) C++17
10 / 100
226 ms 596 KB
#include "insects.h"

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define ar array
#define all(x) x.begin(), x.end()

template <class F, class S>
bool chmin(F &u, const S &v){
	bool flag = false;
	
	if ( u > v ){
		u = v; flag |= true;
	}
	
	return flag;
}

struct Dsu{
	vector <int> fa;
	
	int n;
	
	Dsu(int n) : n(n) {
		fa.resize(n);
		iota(all(fa), 0);
	}
	
	int get(int x){
		return fa[x] ^ x ? fa[x] = get(fa[x]) : x;
	}
	
	bool merge(int u, int v){
		u = get(u), v = get(v);
		
		if ( u == v ) return false;
		
		fa[v] = u;
		
		return true; 
	}
};

int min_cardinality(int n) {
	Dsu ds(n);
	
	for ( int i = 0; i + 1 < n; i++ ){
		move_inside(i);
		
		for ( int j = i + 1; j < n; j++ ){
			move_inside(j);
			
			if ( press_button() == 2 ){
				ds.merge(i, j);
			}
			
			move_outside(j);
		}
		
		move_outside(i);
	}
	
	vector <int> cnt(n);
	
	for ( int i = 0; i < n; i++ ){
		cnt[ds.get(i)]++;
	}
	
	int mn = n;
	
	for ( int i = 0; i < n; i++ ){
		if ( ds.get(i) == i ){
			chmin(mn, cnt[i]);
		}
	}
	
	return mn;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 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 129 ms 344 KB Output is correct
7 Correct 103 ms 344 KB Output is correct
8 Correct 108 ms 344 KB Output is correct
9 Correct 80 ms 344 KB Output is correct
10 Correct 93 ms 596 KB Output is correct
11 Correct 116 ms 344 KB Output is correct
12 Correct 100 ms 344 KB Output is correct
13 Correct 84 ms 344 KB Output is correct
14 Correct 91 ms 344 KB Output is correct
15 Correct 84 ms 344 KB Output is correct
16 Correct 92 ms 344 KB Output is correct
17 Correct 95 ms 344 KB Output is correct
18 Correct 91 ms 344 KB Output is correct
19 Correct 87 ms 344 KB Output is correct
20 Correct 115 ms 344 KB Output is correct
21 Correct 109 ms 344 KB Output is correct
22 Correct 105 ms 340 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 0 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 129 ms 344 KB Output is correct
7 Correct 103 ms 344 KB Output is correct
8 Correct 108 ms 344 KB Output is correct
9 Correct 80 ms 344 KB Output is correct
10 Correct 93 ms 596 KB Output is correct
11 Correct 116 ms 344 KB Output is correct
12 Correct 100 ms 344 KB Output is correct
13 Correct 84 ms 344 KB Output is correct
14 Correct 91 ms 344 KB Output is correct
15 Correct 84 ms 344 KB Output is correct
16 Correct 92 ms 344 KB Output is correct
17 Correct 95 ms 344 KB Output is correct
18 Correct 91 ms 344 KB Output is correct
19 Correct 87 ms 344 KB Output is correct
20 Correct 115 ms 344 KB Output is correct
21 Correct 109 ms 344 KB Output is correct
22 Correct 105 ms 340 KB Output is correct
23 Incorrect 220 ms 344 KB Too many queries.
24 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Partially correct 0 ms 344 KB Output is partially correct
6 Partially correct 0 ms 344 KB Output is partially correct
7 Incorrect 226 ms 344 KB Too many queries.
8 Halted 0 ms 0 KB -