답안 #837170

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
837170 2023-08-25T06:32:59 Z ymm 드문 곤충 (IOI22_insects) C++17
100 / 100
52 ms 440 KB
#include "insects.h"
#include <bits/stdc++.h>
#define Loop(x,l,r) for (ll x = (l); x < (r); ++x)
typedef long long ll;
using namespace std;

#define in move_inside
#define out move_outside
#define get press_button

pair<vector<int>, vector<int>> split(vector<int> vec, int k)
{
	vector<int> vec1, vec2;
	for (int x : vec) {
		in(x);
		if (get() > k) {
			out(x);
			vec2.push_back(x);
		} else {
			vec1.push_back(x);
		}
	}
	for (int x : vec1)
		out(x);
	return {vec1, vec2};
}

int dc(vector<int> vec, int cnt)
{
	if (vec.size() < cnt)
		return 0;
	int k = (vec.size()+2*cnt-1)/(2*cnt);
	auto [v1, v2] = split(vec, k);
	if (v1.size() < cnt * k)
		return dc(v1, cnt);
	else
		return k + dc(v2, cnt);
}

int min_cardinality(int N) {
	vector<int> vec(N);
	iota(vec.begin(), vec.end(), 0);
	auto [v1, v2] = split(vec, 1);
	int cnt = v1.size();
	if (cnt == 1)
		return N;
	return 1 + dc(v2, cnt);
}

Compilation message

insects.cpp: In function 'int dc(std::vector<int>, int)':
insects.cpp:30:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   30 |  if (vec.size() < cnt)
      |      ~~~~~~~~~~~^~~~~
insects.cpp:34:16: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |  if (v1.size() < cnt * k)
      |      ~~~~~~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 2 ms 208 KB Output is correct
7 Correct 2 ms 208 KB Output is correct
8 Correct 4 ms 208 KB Output is correct
9 Correct 4 ms 304 KB Output is correct
10 Correct 5 ms 304 KB Output is correct
11 Correct 2 ms 208 KB Output is correct
12 Correct 3 ms 300 KB Output is correct
13 Correct 4 ms 208 KB Output is correct
14 Correct 4 ms 208 KB Output is correct
15 Correct 5 ms 208 KB Output is correct
16 Correct 4 ms 208 KB Output is correct
17 Correct 4 ms 208 KB Output is correct
18 Correct 5 ms 308 KB Output is correct
19 Correct 4 ms 208 KB Output is correct
20 Correct 4 ms 208 KB Output is correct
21 Correct 2 ms 208 KB Output is correct
22 Correct 2 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 2 ms 208 KB Output is correct
7 Correct 2 ms 208 KB Output is correct
8 Correct 4 ms 208 KB Output is correct
9 Correct 4 ms 304 KB Output is correct
10 Correct 5 ms 304 KB Output is correct
11 Correct 2 ms 208 KB Output is correct
12 Correct 3 ms 300 KB Output is correct
13 Correct 4 ms 208 KB Output is correct
14 Correct 4 ms 208 KB Output is correct
15 Correct 5 ms 208 KB Output is correct
16 Correct 4 ms 208 KB Output is correct
17 Correct 4 ms 208 KB Output is correct
18 Correct 5 ms 308 KB Output is correct
19 Correct 4 ms 208 KB Output is correct
20 Correct 4 ms 208 KB Output is correct
21 Correct 2 ms 208 KB Output is correct
22 Correct 2 ms 208 KB Output is correct
23 Correct 10 ms 304 KB Output is correct
24 Correct 6 ms 208 KB Output is correct
25 Correct 23 ms 308 KB Output is correct
26 Correct 18 ms 316 KB Output is correct
27 Correct 16 ms 208 KB Output is correct
28 Correct 9 ms 316 KB Output is correct
29 Correct 24 ms 208 KB Output is correct
30 Correct 24 ms 304 KB Output is correct
31 Correct 27 ms 316 KB Output is correct
32 Correct 19 ms 308 KB Output is correct
33 Correct 14 ms 312 KB Output is correct
34 Correct 20 ms 304 KB Output is correct
35 Correct 23 ms 312 KB Output is correct
36 Correct 13 ms 316 KB Output is correct
37 Correct 24 ms 308 KB Output is correct
38 Correct 20 ms 308 KB Output is correct
39 Correct 18 ms 208 KB Output is correct
40 Correct 9 ms 312 KB Output is correct
41 Correct 4 ms 308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 14 ms 208 KB Output is correct
8 Correct 8 ms 312 KB Output is correct
9 Correct 41 ms 324 KB Output is correct
10 Correct 50 ms 328 KB Output is correct
11 Correct 24 ms 324 KB Output is correct
12 Correct 25 ms 208 KB Output is correct
13 Correct 41 ms 428 KB Output is correct
14 Correct 37 ms 324 KB Output is correct
15 Correct 22 ms 340 KB Output is correct
16 Correct 48 ms 308 KB Output is correct
17 Correct 52 ms 312 KB Output is correct
18 Correct 24 ms 336 KB Output is correct
19 Correct 41 ms 440 KB Output is correct
20 Correct 50 ms 332 KB Output is correct
21 Correct 49 ms 320 KB Output is correct
22 Correct 47 ms 316 KB Output is correct
23 Correct 42 ms 316 KB Output is correct
24 Correct 34 ms 324 KB Output is correct
25 Correct 27 ms 320 KB Output is correct
26 Correct 16 ms 320 KB Output is correct
27 Correct 25 ms 332 KB Output is correct
28 Correct 33 ms 308 KB Output is correct
29 Correct 43 ms 320 KB Output is correct
30 Correct 38 ms 316 KB Output is correct
31 Correct 36 ms 320 KB Output is correct
32 Correct 37 ms 332 KB Output is correct
33 Correct 46 ms 316 KB Output is correct
34 Correct 40 ms 320 KB Output is correct
35 Correct 39 ms 316 KB Output is correct
36 Correct 35 ms 316 KB Output is correct
37 Correct 35 ms 316 KB Output is correct
38 Correct 25 ms 304 KB Output is correct
39 Correct 44 ms 320 KB Output is correct
40 Correct 37 ms 316 KB Output is correct
41 Correct 39 ms 320 KB Output is correct
42 Correct 42 ms 324 KB Output is correct
43 Correct 5 ms 300 KB Output is correct
44 Correct 33 ms 324 KB Output is correct
45 Correct 25 ms 336 KB Output is correct
46 Correct 22 ms 304 KB Output is correct
47 Correct 20 ms 312 KB Output is correct
48 Correct 20 ms 320 KB Output is correct