답안 #1020128

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1020128 2024-07-11T15:20:55 Z Baytoro Minerals (JOI19_minerals) C++17
100 / 100
33 ms 4812 KB
#include <cstdio>
#include <vector>
#include <assert.h>
#include <iostream>
#include <algorithm>
#include <cmath>

#define pb push_back
using namespace std;
//--------------------------------------------------------------------//
// Do not change this part of the code
/*#ifdef ONLINE_JUDGE
int Query(int x) {
    cout << "q " << x << endl; fflush(stdout);
    int res; fflush(stdin); cin >> res;
    return res;
}
void Answer(int a, int b) {
    cout << "a " << a << " " << b << endl; fflush(stdout);
}
#else*/
// But this part can be changed
#include "minerals.h"
//#include "grader.cpp"
/*int Query(int x) {
    return Query(x);
}
void Answer(int a, int b) {
    return Answer(a, b);
}*/
//#endif
//--------------------------------------------------------------------//
vector<int> used(1e5+5);

int pre=0;
void calc(vector<int> a, vector<int> b, int col){
	if(a.size()==0) return;
	if(a.size()==1){
		if(used[a[0]]) return;
		Answer(a[0],b[0]);
		used[a[0]]=used[b[0]]=1;
		return;
	}
	int k=(0.381*a.size());
	vector<int> f,A,s,B;
	for(int i=0;i<=k;i++) {
		f.pb(a[i]);
		pre=Query(a[i]);
		
	}
	for(int i=k+1;i<a.size();i++)
		s.pb(a[i]);
	for(int i=0;i<b.size();i++){
		if(f.size()==A.size()){
			B.pb(b[i]);
			continue;
		}
		else if(s.size()==B.size()){
			A.pb(b[i]);
			continue;
		}
		int tmp=Query(b[i]);
		if((tmp!=pre)==col) A.pb(b[i]);
		else B.pb(b[i]);
		pre=tmp;
	}
	calc(f,A,col^1);
	calc(s,B,col);
}
void Solve(int n) {
	vector<int> a(2*n+1);
	int last=0;
	vector<int> f,s;
	for(int i=1;i<=2*n;i++){
		int t=Query(i);
		if(t!=last) f.pb(i);
		else s.pb(i);
		last=t;
		pre=t;
	}
	calc(f,s,1);
}
/*
4 
1 5
2 6
3 4
7 8
*/


//--------------------------------------------------------------------//
// Do not change this part of the code
/*#ifdef ONLINE_JUDGE
int main() {
    int N; fflush(stdin); cin >> N;
    Solve(N);
    cout << "f" << endl; fflush(stdout);
}
#endif*/
//--------------------------------------------------------------------//

Compilation message

minerals.cpp: In function 'void calc(std::vector<int>, std::vector<int>, int)':
minerals.cpp:51:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |  for(int i=k+1;i<a.size();i++)
      |                ~^~~~~~~~~
minerals.cpp:53:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |  for(int i=0;i<b.size();i++){
      |              ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 852 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 856 KB Output is correct
4 Correct 0 ms 856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 856 KB Output is correct
2 Correct 3 ms 856 KB Output is correct
3 Correct 3 ms 1112 KB Output is correct
4 Correct 6 ms 1436 KB Output is correct
5 Correct 10 ms 2136 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 852 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 856 KB Output is correct
4 Correct 0 ms 856 KB Output is correct
5 Correct 1 ms 856 KB Output is correct
6 Correct 3 ms 856 KB Output is correct
7 Correct 3 ms 1112 KB Output is correct
8 Correct 6 ms 1436 KB Output is correct
9 Correct 10 ms 2136 KB Output is correct
10 Correct 1 ms 856 KB Output is correct
11 Correct 8 ms 1624 KB Output is correct
12 Correct 13 ms 2136 KB Output is correct
13 Correct 8 ms 2136 KB Output is correct
14 Correct 8 ms 2132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 852 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 856 KB Output is correct
4 Correct 0 ms 856 KB Output is correct
5 Correct 1 ms 856 KB Output is correct
6 Correct 3 ms 856 KB Output is correct
7 Correct 3 ms 1112 KB Output is correct
8 Correct 6 ms 1436 KB Output is correct
9 Correct 10 ms 2136 KB Output is correct
10 Correct 1 ms 856 KB Output is correct
11 Correct 8 ms 1624 KB Output is correct
12 Correct 13 ms 2136 KB Output is correct
13 Correct 8 ms 2136 KB Output is correct
14 Correct 8 ms 2132 KB Output is correct
15 Correct 27 ms 4296 KB Output is correct
16 Correct 28 ms 4296 KB Output is correct
17 Correct 24 ms 4300 KB Output is correct
18 Correct 24 ms 4228 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 852 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 856 KB Output is correct
4 Correct 0 ms 856 KB Output is correct
5 Correct 1 ms 856 KB Output is correct
6 Correct 3 ms 856 KB Output is correct
7 Correct 3 ms 1112 KB Output is correct
8 Correct 6 ms 1436 KB Output is correct
9 Correct 10 ms 2136 KB Output is correct
10 Correct 1 ms 856 KB Output is correct
11 Correct 8 ms 1624 KB Output is correct
12 Correct 13 ms 2136 KB Output is correct
13 Correct 8 ms 2136 KB Output is correct
14 Correct 8 ms 2132 KB Output is correct
15 Correct 27 ms 4296 KB Output is correct
16 Correct 28 ms 4296 KB Output is correct
17 Correct 24 ms 4300 KB Output is correct
18 Correct 24 ms 4228 KB Output is correct
19 Correct 29 ms 4284 KB Output is correct
20 Correct 31 ms 4416 KB Output is correct
21 Correct 24 ms 4436 KB Output is correct
22 Correct 21 ms 4312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 852 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 856 KB Output is correct
4 Correct 0 ms 856 KB Output is correct
5 Correct 1 ms 856 KB Output is correct
6 Correct 3 ms 856 KB Output is correct
7 Correct 3 ms 1112 KB Output is correct
8 Correct 6 ms 1436 KB Output is correct
9 Correct 10 ms 2136 KB Output is correct
10 Correct 1 ms 856 KB Output is correct
11 Correct 8 ms 1624 KB Output is correct
12 Correct 13 ms 2136 KB Output is correct
13 Correct 8 ms 2136 KB Output is correct
14 Correct 8 ms 2132 KB Output is correct
15 Correct 27 ms 4296 KB Output is correct
16 Correct 28 ms 4296 KB Output is correct
17 Correct 24 ms 4300 KB Output is correct
18 Correct 24 ms 4228 KB Output is correct
19 Correct 29 ms 4284 KB Output is correct
20 Correct 31 ms 4416 KB Output is correct
21 Correct 24 ms 4436 KB Output is correct
22 Correct 21 ms 4312 KB Output is correct
23 Correct 28 ms 4380 KB Output is correct
24 Correct 29 ms 4592 KB Output is correct
25 Correct 25 ms 4300 KB Output is correct
26 Correct 21 ms 4288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 852 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 856 KB Output is correct
4 Correct 0 ms 856 KB Output is correct
5 Correct 1 ms 856 KB Output is correct
6 Correct 3 ms 856 KB Output is correct
7 Correct 3 ms 1112 KB Output is correct
8 Correct 6 ms 1436 KB Output is correct
9 Correct 10 ms 2136 KB Output is correct
10 Correct 1 ms 856 KB Output is correct
11 Correct 8 ms 1624 KB Output is correct
12 Correct 13 ms 2136 KB Output is correct
13 Correct 8 ms 2136 KB Output is correct
14 Correct 8 ms 2132 KB Output is correct
15 Correct 27 ms 4296 KB Output is correct
16 Correct 28 ms 4296 KB Output is correct
17 Correct 24 ms 4300 KB Output is correct
18 Correct 24 ms 4228 KB Output is correct
19 Correct 29 ms 4284 KB Output is correct
20 Correct 31 ms 4416 KB Output is correct
21 Correct 24 ms 4436 KB Output is correct
22 Correct 21 ms 4312 KB Output is correct
23 Correct 28 ms 4380 KB Output is correct
24 Correct 29 ms 4592 KB Output is correct
25 Correct 25 ms 4300 KB Output is correct
26 Correct 21 ms 4288 KB Output is correct
27 Correct 31 ms 4616 KB Output is correct
28 Correct 30 ms 4480 KB Output is correct
29 Correct 20 ms 4564 KB Output is correct
30 Correct 23 ms 4624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 852 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 856 KB Output is correct
4 Correct 0 ms 856 KB Output is correct
5 Correct 1 ms 856 KB Output is correct
6 Correct 3 ms 856 KB Output is correct
7 Correct 3 ms 1112 KB Output is correct
8 Correct 6 ms 1436 KB Output is correct
9 Correct 10 ms 2136 KB Output is correct
10 Correct 1 ms 856 KB Output is correct
11 Correct 8 ms 1624 KB Output is correct
12 Correct 13 ms 2136 KB Output is correct
13 Correct 8 ms 2136 KB Output is correct
14 Correct 8 ms 2132 KB Output is correct
15 Correct 27 ms 4296 KB Output is correct
16 Correct 28 ms 4296 KB Output is correct
17 Correct 24 ms 4300 KB Output is correct
18 Correct 24 ms 4228 KB Output is correct
19 Correct 29 ms 4284 KB Output is correct
20 Correct 31 ms 4416 KB Output is correct
21 Correct 24 ms 4436 KB Output is correct
22 Correct 21 ms 4312 KB Output is correct
23 Correct 28 ms 4380 KB Output is correct
24 Correct 29 ms 4592 KB Output is correct
25 Correct 25 ms 4300 KB Output is correct
26 Correct 21 ms 4288 KB Output is correct
27 Correct 31 ms 4616 KB Output is correct
28 Correct 30 ms 4480 KB Output is correct
29 Correct 20 ms 4564 KB Output is correct
30 Correct 23 ms 4624 KB Output is correct
31 Correct 33 ms 4480 KB Output is correct
32 Correct 29 ms 4688 KB Output is correct
33 Correct 21 ms 4692 KB Output is correct
34 Correct 31 ms 4432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 852 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 856 KB Output is correct
4 Correct 0 ms 856 KB Output is correct
5 Correct 1 ms 856 KB Output is correct
6 Correct 3 ms 856 KB Output is correct
7 Correct 3 ms 1112 KB Output is correct
8 Correct 6 ms 1436 KB Output is correct
9 Correct 10 ms 2136 KB Output is correct
10 Correct 1 ms 856 KB Output is correct
11 Correct 8 ms 1624 KB Output is correct
12 Correct 13 ms 2136 KB Output is correct
13 Correct 8 ms 2136 KB Output is correct
14 Correct 8 ms 2132 KB Output is correct
15 Correct 27 ms 4296 KB Output is correct
16 Correct 28 ms 4296 KB Output is correct
17 Correct 24 ms 4300 KB Output is correct
18 Correct 24 ms 4228 KB Output is correct
19 Correct 29 ms 4284 KB Output is correct
20 Correct 31 ms 4416 KB Output is correct
21 Correct 24 ms 4436 KB Output is correct
22 Correct 21 ms 4312 KB Output is correct
23 Correct 28 ms 4380 KB Output is correct
24 Correct 29 ms 4592 KB Output is correct
25 Correct 25 ms 4300 KB Output is correct
26 Correct 21 ms 4288 KB Output is correct
27 Correct 31 ms 4616 KB Output is correct
28 Correct 30 ms 4480 KB Output is correct
29 Correct 20 ms 4564 KB Output is correct
30 Correct 23 ms 4624 KB Output is correct
31 Correct 33 ms 4480 KB Output is correct
32 Correct 29 ms 4688 KB Output is correct
33 Correct 21 ms 4692 KB Output is correct
34 Correct 31 ms 4432 KB Output is correct
35 Correct 33 ms 4604 KB Output is correct
36 Correct 30 ms 4688 KB Output is correct
37 Correct 21 ms 4812 KB Output is correct
38 Correct 27 ms 4624 KB Output is correct