답안 #112608

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
112608 2019-05-20T20:46:45 Z reality Minerals (JOI19_minerals) C++17
100 / 100
63 ms 3540 KB
#include "minerals.h"
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define vii vector < pii >
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class P , class Q > ostream& operator<<(ostream& stream, pair < P , Q > v){ stream << "(" << v.fi << ',' << v.se << ")"; return stream;}
template < class T > ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream;}
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}

const int N = 1e5 + 5;

int cnt;

void Go(vi a,vi b,int ok) {
	random_shuffle(all(b));
	if (a.size() == 1) {
		Answer(a[0],b[0]);
	} else {
		int sz = a.size();
		int m = ceil(0.36 * sz);
		if (ok) {
			m = sz - m;
			for (int i = m;i < sz;++i)
				cnt = Query(a[i]);
		} else {
			for (int i = 0;i < m;++i)
				cnt = Query(a[i]);
		}
		vi x,y;
		for (auto it : b) {
			if (x.size() == m) {
				y.pb(it);
				continue;
			} else
			if (y.size() == sz - m) {
				x.pb(it);
				continue;
			}
			int cur = Query(it);
			if (cnt != cur) {
				y.pb(it);
			} else {
				x.pb(it);
			}
			cnt = cur;
		}
		Go(vi(a.begin(),a.begin() + m),x,1);
		Go(vi(a.begin() + m,a.end()),y,0);
	}
}

void Solve(int N) {
	srand(time(0));
  	vi a,b;
  	for (int i = 1;i <= 2 * N;++i) {
  		int cur = Query(i);
  		if (cnt != cur) {
  			a.pb(i);
  		} else {
  			b.pb(i);
  		}
  		cnt = cur;
  	}
  	Go(a,b,1);
}

Compilation message

minerals.cpp: In function 'void Go(std::vector<int>, std::vector<int>, int)':
minerals.cpp:42:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if (x.size() == m) {
        ~~~~~~~~~^~~~
minerals.cpp:46:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if (y.size() == sz - m) {
        ~~~~~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 4 ms 512 KB Output is correct
3 Correct 6 ms 512 KB Output is correct
4 Correct 11 ms 896 KB Output is correct
5 Correct 20 ms 1408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 4 ms 512 KB Output is correct
7 Correct 6 ms 512 KB Output is correct
8 Correct 11 ms 896 KB Output is correct
9 Correct 20 ms 1408 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 14 ms 1152 KB Output is correct
12 Correct 21 ms 1408 KB Output is correct
13 Correct 20 ms 1344 KB Output is correct
14 Correct 19 ms 1400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 4 ms 512 KB Output is correct
7 Correct 6 ms 512 KB Output is correct
8 Correct 11 ms 896 KB Output is correct
9 Correct 20 ms 1408 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 14 ms 1152 KB Output is correct
12 Correct 21 ms 1408 KB Output is correct
13 Correct 20 ms 1344 KB Output is correct
14 Correct 19 ms 1400 KB Output is correct
15 Correct 54 ms 3084 KB Output is correct
16 Correct 55 ms 3060 KB Output is correct
17 Correct 50 ms 3024 KB Output is correct
18 Correct 49 ms 2676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 4 ms 512 KB Output is correct
7 Correct 6 ms 512 KB Output is correct
8 Correct 11 ms 896 KB Output is correct
9 Correct 20 ms 1408 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 14 ms 1152 KB Output is correct
12 Correct 21 ms 1408 KB Output is correct
13 Correct 20 ms 1344 KB Output is correct
14 Correct 19 ms 1400 KB Output is correct
15 Correct 54 ms 3084 KB Output is correct
16 Correct 55 ms 3060 KB Output is correct
17 Correct 50 ms 3024 KB Output is correct
18 Correct 49 ms 2676 KB Output is correct
19 Correct 56 ms 3188 KB Output is correct
20 Correct 59 ms 3316 KB Output is correct
21 Correct 51 ms 2932 KB Output is correct
22 Correct 53 ms 2808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 4 ms 512 KB Output is correct
7 Correct 6 ms 512 KB Output is correct
8 Correct 11 ms 896 KB Output is correct
9 Correct 20 ms 1408 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 14 ms 1152 KB Output is correct
12 Correct 21 ms 1408 KB Output is correct
13 Correct 20 ms 1344 KB Output is correct
14 Correct 19 ms 1400 KB Output is correct
15 Correct 54 ms 3084 KB Output is correct
16 Correct 55 ms 3060 KB Output is correct
17 Correct 50 ms 3024 KB Output is correct
18 Correct 49 ms 2676 KB Output is correct
19 Correct 56 ms 3188 KB Output is correct
20 Correct 59 ms 3316 KB Output is correct
21 Correct 51 ms 2932 KB Output is correct
22 Correct 53 ms 2808 KB Output is correct
23 Correct 57 ms 3316 KB Output is correct
24 Correct 59 ms 3316 KB Output is correct
25 Correct 54 ms 2980 KB Output is correct
26 Correct 53 ms 2856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 4 ms 512 KB Output is correct
7 Correct 6 ms 512 KB Output is correct
8 Correct 11 ms 896 KB Output is correct
9 Correct 20 ms 1408 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 14 ms 1152 KB Output is correct
12 Correct 21 ms 1408 KB Output is correct
13 Correct 20 ms 1344 KB Output is correct
14 Correct 19 ms 1400 KB Output is correct
15 Correct 54 ms 3084 KB Output is correct
16 Correct 55 ms 3060 KB Output is correct
17 Correct 50 ms 3024 KB Output is correct
18 Correct 49 ms 2676 KB Output is correct
19 Correct 56 ms 3188 KB Output is correct
20 Correct 59 ms 3316 KB Output is correct
21 Correct 51 ms 2932 KB Output is correct
22 Correct 53 ms 2808 KB Output is correct
23 Correct 57 ms 3316 KB Output is correct
24 Correct 59 ms 3316 KB Output is correct
25 Correct 54 ms 2980 KB Output is correct
26 Correct 53 ms 2856 KB Output is correct
27 Correct 60 ms 3316 KB Output is correct
28 Correct 61 ms 3328 KB Output is correct
29 Correct 57 ms 3060 KB Output is correct
30 Correct 54 ms 3016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 4 ms 512 KB Output is correct
7 Correct 6 ms 512 KB Output is correct
8 Correct 11 ms 896 KB Output is correct
9 Correct 20 ms 1408 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 14 ms 1152 KB Output is correct
12 Correct 21 ms 1408 KB Output is correct
13 Correct 20 ms 1344 KB Output is correct
14 Correct 19 ms 1400 KB Output is correct
15 Correct 54 ms 3084 KB Output is correct
16 Correct 55 ms 3060 KB Output is correct
17 Correct 50 ms 3024 KB Output is correct
18 Correct 49 ms 2676 KB Output is correct
19 Correct 56 ms 3188 KB Output is correct
20 Correct 59 ms 3316 KB Output is correct
21 Correct 51 ms 2932 KB Output is correct
22 Correct 53 ms 2808 KB Output is correct
23 Correct 57 ms 3316 KB Output is correct
24 Correct 59 ms 3316 KB Output is correct
25 Correct 54 ms 2980 KB Output is correct
26 Correct 53 ms 2856 KB Output is correct
27 Correct 60 ms 3316 KB Output is correct
28 Correct 61 ms 3328 KB Output is correct
29 Correct 57 ms 3060 KB Output is correct
30 Correct 54 ms 3016 KB Output is correct
31 Correct 63 ms 3444 KB Output is correct
32 Correct 61 ms 3316 KB Output is correct
33 Correct 55 ms 3132 KB Output is correct
34 Correct 55 ms 2932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 4 ms 512 KB Output is correct
7 Correct 6 ms 512 KB Output is correct
8 Correct 11 ms 896 KB Output is correct
9 Correct 20 ms 1408 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 14 ms 1152 KB Output is correct
12 Correct 21 ms 1408 KB Output is correct
13 Correct 20 ms 1344 KB Output is correct
14 Correct 19 ms 1400 KB Output is correct
15 Correct 54 ms 3084 KB Output is correct
16 Correct 55 ms 3060 KB Output is correct
17 Correct 50 ms 3024 KB Output is correct
18 Correct 49 ms 2676 KB Output is correct
19 Correct 56 ms 3188 KB Output is correct
20 Correct 59 ms 3316 KB Output is correct
21 Correct 51 ms 2932 KB Output is correct
22 Correct 53 ms 2808 KB Output is correct
23 Correct 57 ms 3316 KB Output is correct
24 Correct 59 ms 3316 KB Output is correct
25 Correct 54 ms 2980 KB Output is correct
26 Correct 53 ms 2856 KB Output is correct
27 Correct 60 ms 3316 KB Output is correct
28 Correct 61 ms 3328 KB Output is correct
29 Correct 57 ms 3060 KB Output is correct
30 Correct 54 ms 3016 KB Output is correct
31 Correct 63 ms 3444 KB Output is correct
32 Correct 61 ms 3316 KB Output is correct
33 Correct 55 ms 3132 KB Output is correct
34 Correct 55 ms 2932 KB Output is correct
35 Correct 61 ms 3540 KB Output is correct
36 Correct 61 ms 3444 KB Output is correct
37 Correct 57 ms 3188 KB Output is correct
38 Correct 57 ms 3112 KB Output is correct