제출 #1232484

#제출 시각아이디문제언어결과실행 시간메모리
1232484nicolo_010드문 곤충 (IOI22_insects)C++20
10 / 100
99 ms912 KiB
#include <bits/stdc++.h>
#include "insects.h"
using namespace std;
template <typename T>
using v = vector<T>;
using pii = pair<int, int>;
using ll = long long;
#define rep(i, k, n) for (int i = k; i < n; i++)

int sz;
v<bool> vis;
v<v<int>> adj;

void dfs(int n) {
	vis[n] = true;
	sz++;
	for (auto x : adj[n]) {
		if (!vis[x]) {
			dfs(x);
		}
	}
}

int min_cardinality(int N) {
	adj.resize(N);
	rep(i, 0, N) {
		move_inside(i);
		rep(j, i+1, N) {			
			move_inside(j);
			int a = press_button();
			if (a == 2) {
				adj[i].push_back(j);
				adj[j].push_back(i);
			}
			move_outside(j);
		}
		move_outside(i);
	}
	vis.assign(N, false);
	int ans = 1e9;
	rep(i, 0, N) {
		if (!vis[i]) {
			sz = 0;
			dfs(i);
			ans = min(ans, sz);
		}
	}
	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...