답안 #988511

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
988511 2024-05-25T04:40:05 Z cnn008 드문 곤충 (IOI22_insects) C++17
25 / 100
109 ms 692 KB
#include "bits/stdc++.h"
using namespace std;

#include "insects.h"

#ifdef N_N_C
#include "debug.h"
#else
#define cebug(...) "Arya"
#endif

#define ll long long

const int N=1e5+5;
const int mod=1e9+7;

int cad,vis[1005],type;
int min_cardinality(int n){
	for(int i=0; i<n; i++){
		move_inside(i);
		if(press_button()==1) cad++,vis[i]=1;
		else move_outside(i);
	}
	for(int i=0; i<n; i++){
		if(vis[i]){
			vis[i]=0;
			move_outside(i);
		}
	}
	if(cad<=30){
		for(int i=0; i<n; i++){
			if(!vis[i]){
				vis[i]=++type;
				move_inside(i);
				for(int j=i+1; j<n; j++){
					move_inside(j);
					int val=press_button();
					if(val==2) vis[j]=type;
					move_outside(j);
				}
				move_outside(i);
			}
		}
		map <int,int> mp;
		for(int i=0; i<n; i++) mp[vis[i]]++;
		int ans=INT_MAX;
		for(auto [x,y]:mp) ans=min(ans,y);
		return ans;
	}else{
		int cnt=0;
		for(int i=0; i<n; i++){
			if(!vis[i]){
				cnt++;
				vis[i]=++type;
				move_inside(i);
				int sz=1;
				for(int j=i+1; j<n; j++){
					if(vis[j]) continue;
					move_inside(j);
					if(press_button()==1){
						sz++;
						vis[j]=type;
					}else move_outside(j);
				}
				if(sz<cad) return cnt-1;
				move_outside(i);
				for(int j=i+1; j<n; j++) if(vis[j]==type) move_outside(j);
			}
		}
		return cnt;
	}
}
/**  /\_/\
*   (= ._.)
*   / >💖 \>💕
**/

Compilation message

insects.cpp:73:9: warning: "/*" within comment [-Wcomment]
   73 | /**  /\_/\
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 356 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Correct 11 ms 344 KB Output is correct
9 Correct 13 ms 344 KB Output is correct
10 Correct 4 ms 344 KB Output is correct
11 Correct 3 ms 344 KB Output is correct
12 Correct 6 ms 596 KB Output is correct
13 Correct 11 ms 344 KB Output is correct
14 Correct 5 ms 344 KB Output is correct
15 Correct 7 ms 344 KB Output is correct
16 Correct 9 ms 344 KB Output is correct
17 Correct 11 ms 344 KB Output is correct
18 Correct 14 ms 344 KB Output is correct
19 Correct 19 ms 344 KB Output is correct
20 Correct 3 ms 344 KB Output is correct
21 Correct 3 ms 344 KB Output is correct
22 Correct 2 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 356 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 2 ms 344 KB Output is correct
8 Correct 11 ms 344 KB Output is correct
9 Correct 13 ms 344 KB Output is correct
10 Correct 4 ms 344 KB Output is correct
11 Correct 3 ms 344 KB Output is correct
12 Correct 6 ms 596 KB Output is correct
13 Correct 11 ms 344 KB Output is correct
14 Correct 5 ms 344 KB Output is correct
15 Correct 7 ms 344 KB Output is correct
16 Correct 9 ms 344 KB Output is correct
17 Correct 11 ms 344 KB Output is correct
18 Correct 14 ms 344 KB Output is correct
19 Correct 19 ms 344 KB Output is correct
20 Correct 3 ms 344 KB Output is correct
21 Correct 3 ms 344 KB Output is correct
22 Correct 2 ms 344 KB Output is correct
23 Correct 9 ms 344 KB Output is correct
24 Correct 12 ms 600 KB Output is correct
25 Correct 73 ms 344 KB Output is correct
26 Correct 71 ms 344 KB Output is correct
27 Correct 13 ms 344 KB Output is correct
28 Correct 12 ms 344 KB Output is correct
29 Correct 28 ms 344 KB Output is correct
30 Correct 13 ms 344 KB Output is correct
31 Correct 25 ms 344 KB Output is correct
32 Correct 40 ms 344 KB Output is correct
33 Correct 68 ms 344 KB Output is correct
34 Correct 62 ms 344 KB Output is correct
35 Correct 84 ms 344 KB Output is correct
36 Correct 109 ms 344 KB Output is correct
37 Correct 47 ms 344 KB Output is correct
38 Correct 20 ms 344 KB Output is correct
39 Correct 13 ms 344 KB Output is correct
40 Correct 10 ms 344 KB Output is correct
41 Correct 10 ms 692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Runtime error 17 ms 436 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -