QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#142828#4565. Rarest InsectsAPROHACK#Compile Error//C++14948b2023-08-20 00:02:302024-07-04 01:49:15

Judging History

你现在查看的是最新测评结果

  • [2024-07-04 01:49:15]
  • 评测
  • [2023-08-20 00:02:30]
  • 提交

answer

#include "insects.h"
#include <vector>
#include <climits>
#include <iostream>
//#include <algobase.h>
using namespace std;
#define ll long long 
#define ff first
#define ss second
#define pb push_back
int rep[10001];
int n ;
bool in[10001];
int cnt[10001];
bool past[10001];

void joinn(int a, int b){
	if(!in[a])move_inside(a);
	if(!in[b])move_inside(b);
	int k = press_button();
	if(k == 2){
		rep[b] = a;
		cnt[a] ++ ;
		cnt[b] = INT_MAX;
		past[a] = true;
		past[b] = true;
	}
}

int min_cardinality(int N) {
	for(int i = 0 ; i < N ; i ++){
		rep[i] = i;
		in[i] = false;
		cnt[i] = 1;
		past[i] = false;
	}
	n = N;
	for(int i = 0 ; i < n-1 ; i ++){
		if(past[i])continue;
		for(int j = i+1 ; j < n ; j ++){
			if(past[j])continue;
			joinn(i, j);
			move_outside(j);
		}
		move_outside(i);
	}
	int mini = INT_MAX;
	for(int i = 0 ; i < n ; i ++){
		//cout << "i = " << i << " " << cnt[i] << "\n";
		mini = min(mini, cnt[i]);
	}
	return mini;
}

Details