답안 #486643

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
486643 2021-11-12T08:03:21 Z cheissmart Minerals (JOI19_minerals) C++14
100 / 100
48 ms 3980 KB
#include "minerals.h"
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

string _reset = "\u001b[0m", _yellow = "\u001b[33m", _bold = "\u001b[1m";
void DBG() { cerr << "]" << _reset << endl; }
template<class H, class...T> void DBG(H h, T ...t) {
  cerr << to_string(h);
  if(sizeof ...(t)) cerr << ", ";
  DBG(t...);
}
#ifdef CHEISSMART
#define debug(...) cerr << _yellow << _bold << "Line(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define debug(...)
#endif

const int INF = 1e9 + 7;

int now;

bool isin(int i) {
	int pre = now;
	now = Query(i);
	return pre == now;
}

void solve(vi a, vi b, int n, bool in) {
	assert(int(a.size()) == n);
	assert(int(b.size()) == n);
	if(n == 1) {
		Answer(a[0], b[0]);	
		return;
	}
	int m = max(1, int(0.382 * n));
	vi al, bl, ar, br;
	for(int i = 0; i < m; i++) {
		now = Query(a[i]);
		al.PB(a[i]);
	}
	for(int i = m; i < n; i++)
		ar.PB(a[i]);
	for(int i:b) {
		if(int(bl.size() == m)) br.PB(i);
		else if(int(br.size()) == n - m) bl.PB(i);
		else {
			if(isin(i)) {
				if(in) br.PB(i);
				else bl.PB(i);
			} else {
				if(in) bl.PB(i);
				else br.PB(i);
			}
		}
	}
	solve(al, bl, m, !in);
	solve(ar, br, n - m, in);
}

void Solve(int n) {
	int pre = 0;
	vi a, b;
	for(int i = 1; i <= 2 * n; i++) {
		now = Query(i);
		if(pre == now)
			a.PB(i);
		else
			b.PB(i);
		pre = now;
	}
	solve(a, b, n, true);
}

Compilation message

minerals.cpp: In function 'void solve(vi, vi, int, bool)':
minerals.cpp:57:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   57 |   if(int(bl.size() == m)) br.PB(i);
      |          ~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 2 ms 456 KB Output is correct
3 Correct 4 ms 584 KB Output is correct
4 Correct 11 ms 976 KB Output is correct
5 Correct 14 ms 1508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Correct 4 ms 584 KB Output is correct
8 Correct 11 ms 976 KB Output is correct
9 Correct 14 ms 1508 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 11 ms 1096 KB Output is correct
12 Correct 14 ms 1604 KB Output is correct
13 Correct 11 ms 1524 KB Output is correct
14 Correct 14 ms 1564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Correct 4 ms 584 KB Output is correct
8 Correct 11 ms 976 KB Output is correct
9 Correct 14 ms 1508 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 11 ms 1096 KB Output is correct
12 Correct 14 ms 1604 KB Output is correct
13 Correct 11 ms 1524 KB Output is correct
14 Correct 14 ms 1564 KB Output is correct
15 Correct 40 ms 3440 KB Output is correct
16 Correct 42 ms 3540 KB Output is correct
17 Correct 30 ms 3592 KB Output is correct
18 Correct 32 ms 3432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Correct 4 ms 584 KB Output is correct
8 Correct 11 ms 976 KB Output is correct
9 Correct 14 ms 1508 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 11 ms 1096 KB Output is correct
12 Correct 14 ms 1604 KB Output is correct
13 Correct 11 ms 1524 KB Output is correct
14 Correct 14 ms 1564 KB Output is correct
15 Correct 40 ms 3440 KB Output is correct
16 Correct 42 ms 3540 KB Output is correct
17 Correct 30 ms 3592 KB Output is correct
18 Correct 32 ms 3432 KB Output is correct
19 Correct 40 ms 3636 KB Output is correct
20 Correct 45 ms 3628 KB Output is correct
21 Correct 31 ms 3548 KB Output is correct
22 Correct 33 ms 3436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Correct 4 ms 584 KB Output is correct
8 Correct 11 ms 976 KB Output is correct
9 Correct 14 ms 1508 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 11 ms 1096 KB Output is correct
12 Correct 14 ms 1604 KB Output is correct
13 Correct 11 ms 1524 KB Output is correct
14 Correct 14 ms 1564 KB Output is correct
15 Correct 40 ms 3440 KB Output is correct
16 Correct 42 ms 3540 KB Output is correct
17 Correct 30 ms 3592 KB Output is correct
18 Correct 32 ms 3432 KB Output is correct
19 Correct 40 ms 3636 KB Output is correct
20 Correct 45 ms 3628 KB Output is correct
21 Correct 31 ms 3548 KB Output is correct
22 Correct 33 ms 3436 KB Output is correct
23 Correct 42 ms 3632 KB Output is correct
24 Correct 41 ms 3628 KB Output is correct
25 Correct 37 ms 3628 KB Output is correct
26 Correct 33 ms 3528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Correct 4 ms 584 KB Output is correct
8 Correct 11 ms 976 KB Output is correct
9 Correct 14 ms 1508 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 11 ms 1096 KB Output is correct
12 Correct 14 ms 1604 KB Output is correct
13 Correct 11 ms 1524 KB Output is correct
14 Correct 14 ms 1564 KB Output is correct
15 Correct 40 ms 3440 KB Output is correct
16 Correct 42 ms 3540 KB Output is correct
17 Correct 30 ms 3592 KB Output is correct
18 Correct 32 ms 3432 KB Output is correct
19 Correct 40 ms 3636 KB Output is correct
20 Correct 45 ms 3628 KB Output is correct
21 Correct 31 ms 3548 KB Output is correct
22 Correct 33 ms 3436 KB Output is correct
23 Correct 42 ms 3632 KB Output is correct
24 Correct 41 ms 3628 KB Output is correct
25 Correct 37 ms 3628 KB Output is correct
26 Correct 33 ms 3528 KB Output is correct
27 Correct 42 ms 3664 KB Output is correct
28 Correct 42 ms 3716 KB Output is correct
29 Correct 34 ms 3776 KB Output is correct
30 Correct 37 ms 3552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Correct 4 ms 584 KB Output is correct
8 Correct 11 ms 976 KB Output is correct
9 Correct 14 ms 1508 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 11 ms 1096 KB Output is correct
12 Correct 14 ms 1604 KB Output is correct
13 Correct 11 ms 1524 KB Output is correct
14 Correct 14 ms 1564 KB Output is correct
15 Correct 40 ms 3440 KB Output is correct
16 Correct 42 ms 3540 KB Output is correct
17 Correct 30 ms 3592 KB Output is correct
18 Correct 32 ms 3432 KB Output is correct
19 Correct 40 ms 3636 KB Output is correct
20 Correct 45 ms 3628 KB Output is correct
21 Correct 31 ms 3548 KB Output is correct
22 Correct 33 ms 3436 KB Output is correct
23 Correct 42 ms 3632 KB Output is correct
24 Correct 41 ms 3628 KB Output is correct
25 Correct 37 ms 3628 KB Output is correct
26 Correct 33 ms 3528 KB Output is correct
27 Correct 42 ms 3664 KB Output is correct
28 Correct 42 ms 3716 KB Output is correct
29 Correct 34 ms 3776 KB Output is correct
30 Correct 37 ms 3552 KB Output is correct
31 Correct 44 ms 3832 KB Output is correct
32 Correct 44 ms 3788 KB Output is correct
33 Correct 33 ms 3796 KB Output is correct
34 Correct 34 ms 3584 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 456 KB Output is correct
7 Correct 4 ms 584 KB Output is correct
8 Correct 11 ms 976 KB Output is correct
9 Correct 14 ms 1508 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 11 ms 1096 KB Output is correct
12 Correct 14 ms 1604 KB Output is correct
13 Correct 11 ms 1524 KB Output is correct
14 Correct 14 ms 1564 KB Output is correct
15 Correct 40 ms 3440 KB Output is correct
16 Correct 42 ms 3540 KB Output is correct
17 Correct 30 ms 3592 KB Output is correct
18 Correct 32 ms 3432 KB Output is correct
19 Correct 40 ms 3636 KB Output is correct
20 Correct 45 ms 3628 KB Output is correct
21 Correct 31 ms 3548 KB Output is correct
22 Correct 33 ms 3436 KB Output is correct
23 Correct 42 ms 3632 KB Output is correct
24 Correct 41 ms 3628 KB Output is correct
25 Correct 37 ms 3628 KB Output is correct
26 Correct 33 ms 3528 KB Output is correct
27 Correct 42 ms 3664 KB Output is correct
28 Correct 42 ms 3716 KB Output is correct
29 Correct 34 ms 3776 KB Output is correct
30 Correct 37 ms 3552 KB Output is correct
31 Correct 44 ms 3832 KB Output is correct
32 Correct 44 ms 3788 KB Output is correct
33 Correct 33 ms 3796 KB Output is correct
34 Correct 34 ms 3584 KB Output is correct
35 Correct 43 ms 3900 KB Output is correct
36 Correct 48 ms 3864 KB Output is correct
37 Correct 34 ms 3980 KB Output is correct
38 Correct 36 ms 3720 KB Output is correct