답안 #837430

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
837430 2023-08-25T10:47:25 Z NothingXD 드문 곤충 (IOI22_insects) C++17
50.17 / 100
124 ms 500 KB
#include "insects.h"
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

void debug_out(){cerr<<endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T){
	cerr << H << ' ';
	debug_out(T...);
}

#define debug(...) cerr << "(" << #__VA_ARGS__ << "): ", debug_out(__VA_ARGS__)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define MP(x, y) make_pair(x, y)

const int maxn = 2e3 + 10;
const int lg = 20;
int l[maxn], r[maxn], cnt[maxn];
vector<int> a, b;
vector<int> idx[maxn];

bool check_empty(int x){
	for (int i = x; i < a.size(); i++){
		if (!idx[i].empty()) return false;
	}
	return true;
}

int min_cardinality(int N) {
	int n = N;
	vector<int> A;
	for (int i = 0; i < n; i++) A.push_back(i);
	for (auto i: A){
		move_inside(i);
		if (press_button() == 2){
			move_outside(i);
			l[b.size()] = -1;
			r[b.size()] = a.size();
			b.push_back(i);
			continue;
		}
		//debug(i);
		a.push_back(i);
	}
	for (int i = 0; i < a.size(); i++){
		move_outside(a[i]);
	}
	for (int i = 0; i < b.size(); i++){
		if (l[i] + 1 < r[i]){
			int mid = (l[i] + r[i]) >> 1;
			idx[mid].push_back(i);
		}
	}
	//debug(a.size(), b.size());
	while(!check_empty(0)){
		for (int j = 0; j < a.size(); j++){
			move_inside(a[j]);
			for (auto x: idx[j]){
				move_inside(b[x]);
			//	debug(j, x, b[x], press_button());
				if (press_button() == 2) r[x] = j;
				else l[x] = j;
				if (l[x] + 1 < r[x]){
					int mid = (l[x] + r[x]) >> 1;
					idx[mid].push_back(x);
				}
				move_outside(b[x]);
			}
			idx[j].clear();
		}
		//for (int i = 0; i < b.size(); i++) debug(i, l[i], r[i]);
		for (int j = 0; j < a.size(); j++){
			move_outside(a[j]);
		}
	}

	for (int i = 0; i < b.size(); i++){
		cnt[r[i]]++;
	}
	int ans = n;
	for (int i = 0; i < a.size(); i++){
		ans = min(ans, cnt[i]);
	//	debug(cnt[i]);
	}
	return ans+1;
}

Compilation message

insects.cpp: In function 'bool check_empty(int)':
insects.cpp:30:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |  for (int i = x; i < a.size(); i++){
      |                  ~~^~~~~~~~~~
insects.cpp: In function 'int min_cardinality(int)':
insects.cpp:52:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |  for (int i = 0; i < a.size(); i++){
      |                  ~~^~~~~~~~~~
insects.cpp:55:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |  for (int i = 0; i < b.size(); i++){
      |                  ~~^~~~~~~~~~
insects.cpp:63:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |   for (int j = 0; j < a.size(); j++){
      |                   ~~^~~~~~~~~~
insects.cpp:79:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |   for (int j = 0; j < a.size(); j++){
      |                   ~~^~~~~~~~~~
insects.cpp:84:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   84 |  for (int i = 0; i < b.size(); i++){
      |                  ~~^~~~~~~~~~
insects.cpp:88:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   88 |  for (int i = 0; i < a.size(); i++){
      |                  ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 4 ms 336 KB Output is correct
7 Correct 2 ms 336 KB Output is correct
8 Correct 7 ms 336 KB Output is correct
9 Correct 7 ms 336 KB Output is correct
10 Correct 5 ms 336 KB Output is correct
11 Correct 6 ms 388 KB Output is correct
12 Correct 5 ms 336 KB Output is correct
13 Correct 7 ms 340 KB Output is correct
14 Correct 5 ms 388 KB Output is correct
15 Correct 6 ms 368 KB Output is correct
16 Correct 8 ms 336 KB Output is correct
17 Correct 5 ms 336 KB Output is correct
18 Correct 10 ms 336 KB Output is correct
19 Correct 7 ms 336 KB Output is correct
20 Correct 7 ms 336 KB Output is correct
21 Correct 8 ms 360 KB Output is correct
22 Correct 7 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 4 ms 336 KB Output is correct
7 Correct 2 ms 336 KB Output is correct
8 Correct 7 ms 336 KB Output is correct
9 Correct 7 ms 336 KB Output is correct
10 Correct 5 ms 336 KB Output is correct
11 Correct 6 ms 388 KB Output is correct
12 Correct 5 ms 336 KB Output is correct
13 Correct 7 ms 340 KB Output is correct
14 Correct 5 ms 388 KB Output is correct
15 Correct 6 ms 368 KB Output is correct
16 Correct 8 ms 336 KB Output is correct
17 Correct 5 ms 336 KB Output is correct
18 Correct 10 ms 336 KB Output is correct
19 Correct 7 ms 336 KB Output is correct
20 Correct 7 ms 336 KB Output is correct
21 Correct 8 ms 360 KB Output is correct
22 Correct 7 ms 364 KB Output is correct
23 Correct 18 ms 336 KB Output is correct
24 Correct 10 ms 360 KB Output is correct
25 Correct 53 ms 376 KB Output is correct
26 Correct 52 ms 372 KB Output is correct
27 Correct 10 ms 372 KB Output is correct
28 Correct 36 ms 364 KB Output is correct
29 Correct 21 ms 336 KB Output is correct
30 Correct 61 ms 376 KB Output is correct
31 Correct 26 ms 376 KB Output is correct
32 Correct 33 ms 380 KB Output is correct
33 Correct 31 ms 500 KB Output is correct
34 Correct 36 ms 372 KB Output is correct
35 Correct 40 ms 372 KB Output is correct
36 Correct 35 ms 372 KB Output is correct
37 Correct 48 ms 372 KB Output is correct
38 Correct 51 ms 360 KB Output is correct
39 Correct 38 ms 376 KB Output is correct
40 Correct 34 ms 336 KB Output is correct
41 Correct 32 ms 380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 0 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 25 ms 376 KB Output is correct
8 Correct 14 ms 368 KB Output is correct
9 Partially correct 100 ms 408 KB Output is partially correct
10 Partially correct 108 ms 428 KB Output is partially correct
11 Correct 26 ms 376 KB Output is correct
12 Partially correct 69 ms 404 KB Output is partially correct
13 Partially correct 50 ms 400 KB Output is partially correct
14 Partially correct 88 ms 412 KB Output is partially correct
15 Partially correct 60 ms 336 KB Output is partially correct
16 Partially correct 43 ms 396 KB Output is partially correct
17 Partially correct 37 ms 404 KB Output is partially correct
18 Partially correct 71 ms 380 KB Output is partially correct
19 Partially correct 40 ms 396 KB Output is partially correct
20 Partially correct 71 ms 388 KB Output is partially correct
21 Partially correct 93 ms 408 KB Output is partially correct
22 Partially correct 55 ms 500 KB Output is partially correct
23 Partially correct 90 ms 432 KB Output is partially correct
24 Partially correct 78 ms 424 KB Output is partially correct
25 Partially correct 72 ms 416 KB Output is partially correct
26 Partially correct 79 ms 400 KB Output is partially correct
27 Partially correct 70 ms 408 KB Output is partially correct
28 Partially correct 48 ms 404 KB Output is partially correct
29 Partially correct 70 ms 416 KB Output is partially correct
30 Partially correct 55 ms 336 KB Output is partially correct
31 Partially correct 87 ms 396 KB Output is partially correct
32 Partially correct 112 ms 416 KB Output is partially correct
33 Partially correct 91 ms 416 KB Output is partially correct
34 Partially correct 124 ms 336 KB Output is partially correct
35 Partially correct 116 ms 400 KB Output is partially correct
36 Partially correct 56 ms 496 KB Output is partially correct
37 Partially correct 86 ms 412 KB Output is partially correct
38 Partially correct 71 ms 400 KB Output is partially correct
39 Partially correct 90 ms 416 KB Output is partially correct
40 Partially correct 96 ms 412 KB Output is partially correct
41 Partially correct 78 ms 408 KB Output is partially correct
42 Partially correct 80 ms 416 KB Output is partially correct
43 Partially correct 15 ms 368 KB Output is partially correct
44 Partially correct 30 ms 388 KB Output is partially correct
45 Correct 38 ms 372 KB Output is correct
46 Partially correct 28 ms 376 KB Output is partially correct
47 Partially correct 70 ms 404 KB Output is partially correct
48 Partially correct 76 ms 396 KB Output is partially correct