답안 #156905

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
156905 2019-10-08T08:36:15 Z popovicirobert Minerals (JOI19_minerals) C++14
40 / 100
68 ms 2792 KB
#include "minerals.h"
#include <bits/stdc++.h>

using namespace std;

void solve(vector <int> &l, vector <int> &r) {
	if(l.empty()) {
		return ;
	}
	if(l.size() == 1) {
		Answer(l[0], r[0]);
		return ;
	}

	random_shuffle(l.begin(), l.end());
	random_shuffle(r.begin(), r.end());
	
	int mid = (0 + l.size()) / 3;
	vector <int> l1, l2;
	int i, ans = 0;
	for(i = 0; i <= mid; i++) {
		l1.push_back(l[i]);
		ans = Query(l[i]);
	}
	for(i = mid + 1; i < l.size(); i++) {
		l2.push_back(l[i]);
	}
	vector <int> r1, r2;
	for(i = 0; i < r.size(); i++) {
		if(r1.size() == l1.size()) {
			r2.push_back(r[i]);
			continue;
		}
		if(r2.size() == l2.size()) {
			r1.push_back(r[i]);
			continue;
		}
		int cur = Query(r[i]);
		if(cur == ans) {
			r1.push_back(r[i]);
		}
		else {
			r2.push_back(r[i]);
		}
		Query(r[i]);
	}
	for(auto it : l1) {
		Query(it);
	}

	solve(l1, r1);
	solve(l2, r2);
}

void Solve(int n) {
	srand(time(NULL));
	vector <int> l, r;
	int ans = 0;
	for(int i = 0; i < 2 * n; i++) {
		int cur = Query(i + 1);
		if(cur == ans) {
			l.push_back(i + 1);
		}
		else {
			r.push_back(i + 1);
		}
		ans = cur;
	}
	for(int i = 0; i < 2 * n; i++) {
		Query(i + 1);
	}
	solve(l, r);
}

Compilation message

minerals.cpp: In function 'void solve(std::vector<int>&, std::vector<int>&)':
minerals.cpp:25:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(i = mid + 1; i < l.size(); i++) {
                   ~~^~~~~~~~~~
minerals.cpp:29:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(i = 0; i < r.size(); i++) {
             ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 380 KB Output is correct
2 Correct 6 ms 504 KB Output is correct
3 Correct 10 ms 504 KB Output is correct
4 Correct 20 ms 888 KB Output is correct
5 Correct 38 ms 1264 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 252 KB Output is correct
5 Correct 4 ms 380 KB Output is correct
6 Correct 6 ms 504 KB Output is correct
7 Correct 10 ms 504 KB Output is correct
8 Correct 20 ms 888 KB Output is correct
9 Correct 38 ms 1264 KB Output is correct
10 Correct 4 ms 376 KB Output is correct
11 Correct 26 ms 1144 KB Output is correct
12 Correct 39 ms 1400 KB Output is correct
13 Correct 39 ms 1400 KB Output is correct
14 Correct 38 ms 1304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 252 KB Output is correct
5 Correct 4 ms 380 KB Output is correct
6 Correct 6 ms 504 KB Output is correct
7 Correct 10 ms 504 KB Output is correct
8 Correct 20 ms 888 KB Output is correct
9 Correct 38 ms 1264 KB Output is correct
10 Correct 4 ms 376 KB Output is correct
11 Correct 26 ms 1144 KB Output is correct
12 Correct 39 ms 1400 KB Output is correct
13 Correct 39 ms 1400 KB Output is correct
14 Correct 38 ms 1304 KB Output is correct
15 Incorrect 68 ms 2792 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 252 KB Output is correct
5 Correct 4 ms 380 KB Output is correct
6 Correct 6 ms 504 KB Output is correct
7 Correct 10 ms 504 KB Output is correct
8 Correct 20 ms 888 KB Output is correct
9 Correct 38 ms 1264 KB Output is correct
10 Correct 4 ms 376 KB Output is correct
11 Correct 26 ms 1144 KB Output is correct
12 Correct 39 ms 1400 KB Output is correct
13 Correct 39 ms 1400 KB Output is correct
14 Correct 38 ms 1304 KB Output is correct
15 Incorrect 68 ms 2792 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 252 KB Output is correct
5 Correct 4 ms 380 KB Output is correct
6 Correct 6 ms 504 KB Output is correct
7 Correct 10 ms 504 KB Output is correct
8 Correct 20 ms 888 KB Output is correct
9 Correct 38 ms 1264 KB Output is correct
10 Correct 4 ms 376 KB Output is correct
11 Correct 26 ms 1144 KB Output is correct
12 Correct 39 ms 1400 KB Output is correct
13 Correct 39 ms 1400 KB Output is correct
14 Correct 38 ms 1304 KB Output is correct
15 Incorrect 68 ms 2792 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 252 KB Output is correct
5 Correct 4 ms 380 KB Output is correct
6 Correct 6 ms 504 KB Output is correct
7 Correct 10 ms 504 KB Output is correct
8 Correct 20 ms 888 KB Output is correct
9 Correct 38 ms 1264 KB Output is correct
10 Correct 4 ms 376 KB Output is correct
11 Correct 26 ms 1144 KB Output is correct
12 Correct 39 ms 1400 KB Output is correct
13 Correct 39 ms 1400 KB Output is correct
14 Correct 38 ms 1304 KB Output is correct
15 Incorrect 68 ms 2792 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 252 KB Output is correct
5 Correct 4 ms 380 KB Output is correct
6 Correct 6 ms 504 KB Output is correct
7 Correct 10 ms 504 KB Output is correct
8 Correct 20 ms 888 KB Output is correct
9 Correct 38 ms 1264 KB Output is correct
10 Correct 4 ms 376 KB Output is correct
11 Correct 26 ms 1144 KB Output is correct
12 Correct 39 ms 1400 KB Output is correct
13 Correct 39 ms 1400 KB Output is correct
14 Correct 38 ms 1304 KB Output is correct
15 Incorrect 68 ms 2792 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 252 KB Output is correct
5 Correct 4 ms 380 KB Output is correct
6 Correct 6 ms 504 KB Output is correct
7 Correct 10 ms 504 KB Output is correct
8 Correct 20 ms 888 KB Output is correct
9 Correct 38 ms 1264 KB Output is correct
10 Correct 4 ms 376 KB Output is correct
11 Correct 26 ms 1144 KB Output is correct
12 Correct 39 ms 1400 KB Output is correct
13 Correct 39 ms 1400 KB Output is correct
14 Correct 38 ms 1304 KB Output is correct
15 Incorrect 68 ms 2792 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -