답안 #767851

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
767851 2023-06-27T08:27:25 Z minhcool Minerals (JOI19_minerals) C++17
90 / 100
33 ms 5284 KB
//#define local
#ifndef local
#include "minerals.h"
#endif
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
//#define int long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;
 
const int N = 3e5 + 5;
 
const int oo = 1e18 + 7, mod = 1e9 + 7;
 
mt19937 rng(1);
 
int rnd(int l, int r){
	int temp = rng() % (r - l + 1);
	return abs(temp) + l;
}
 
vector<int> fi, se;
 
#define index indexx
int index[N];
 
bool in[N];

bool used[N];

int total[N][17];
 
void Solve(int N){
	int lst = 0;
	for(int i = 1; i <= 2 * N; i++){
		int temp = Query(i);
		in[i] = 1;
		if(temp == lst) se.pb(i);
		else fi.pb(i);
		lst = temp;
	}
	for(int i = 0; i < N; i++){
		int num = 0;
		for(int j = 0; j <= 15; j++){
			if(i & (1LL << j)) num += (1LL << j);
			total[num][j]++;
		}
	}
	bool temp = 1;
	shuffle(se.begin(), se.end(), default_random_engine(7405));
	for(int i = 0; i <= 15; i++){
		int num = 0;
		for(int j = 0; j < fi.size(); j++){
			bool temp1 = in[fi[j]], temp2 = (j & (1LL << i));
			if(i == 15 && temp1) continue;
			if(temp1 ^ temp2){
				num++;
				lst = Query(fi[j]);
				in[fi[j]] ^= 1;
			}
		}
	//	cout << i << " " << num << "\n";
		for(auto it : se){
			//if(i == 14 && (used[index[it] + (1LL << 14)])) continue;
			if(!total[index[it]][i]){
				index[it] += (1LL << i);
				continue;
			}
			if(!total[index[it] + (1LL << i)][i]){
				continue;
			}
			int temp = Query(it);
			if(lst == temp) index[it] += (1LL << i);
			total[index[it]][i]--;
			//if(i == 14 && (index[it] + (1LL << 15)) >= fi.size()) used[index[it]] = 1;
			//in[it] ^= 1;
			lst = temp;
		}
		//temp ^= 1;	
	}
	//for(auto it : se) cout << index[it] << " " << fi[index[it]] << "\n";
	for(auto it : se) Answer(fi[index[it]], it);
}
 
#ifdef local
void process(){
 
}
 
signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t;
	cin >> t;
	while(t--) process();
}
#endif

Compilation message

minerals.cpp:22:21: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   22 | const int oo = 1e18 + 7, mod = 1e9 + 7;
      |                ~~~~~^~~
minerals.cpp: In function 'void Solve(int)':
minerals.cpp:62:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |   for(int j = 0; j < fi.size(); j++){
      |                  ~~^~~~~~~~~~~
minerals.cpp:58:7: warning: unused variable 'temp' [-Wunused-variable]
   58 |  bool temp = 1;
      |       ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 464 KB Output is correct
3 Correct 3 ms 720 KB Output is correct
4 Correct 4 ms 1232 KB Output is correct
5 Correct 8 ms 2000 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 464 KB Output is correct
7 Correct 3 ms 720 KB Output is correct
8 Correct 4 ms 1232 KB Output is correct
9 Correct 8 ms 2000 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 6 ms 1488 KB Output is correct
12 Correct 8 ms 2128 KB Output is correct
13 Correct 8 ms 2076 KB Output is correct
14 Correct 8 ms 1904 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 464 KB Output is correct
7 Correct 3 ms 720 KB Output is correct
8 Correct 4 ms 1232 KB Output is correct
9 Correct 8 ms 2000 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 6 ms 1488 KB Output is correct
12 Correct 8 ms 2128 KB Output is correct
13 Correct 8 ms 2076 KB Output is correct
14 Correct 8 ms 1904 KB Output is correct
15 Correct 28 ms 4728 KB Output is correct
16 Correct 27 ms 4824 KB Output is correct
17 Correct 23 ms 4868 KB Output is correct
18 Correct 26 ms 4424 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 464 KB Output is correct
7 Correct 3 ms 720 KB Output is correct
8 Correct 4 ms 1232 KB Output is correct
9 Correct 8 ms 2000 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 6 ms 1488 KB Output is correct
12 Correct 8 ms 2128 KB Output is correct
13 Correct 8 ms 2076 KB Output is correct
14 Correct 8 ms 1904 KB Output is correct
15 Correct 28 ms 4728 KB Output is correct
16 Correct 27 ms 4824 KB Output is correct
17 Correct 23 ms 4868 KB Output is correct
18 Correct 26 ms 4424 KB Output is correct
19 Correct 31 ms 4936 KB Output is correct
20 Correct 29 ms 4912 KB Output is correct
21 Correct 24 ms 5012 KB Output is correct
22 Correct 30 ms 4680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 464 KB Output is correct
7 Correct 3 ms 720 KB Output is correct
8 Correct 4 ms 1232 KB Output is correct
9 Correct 8 ms 2000 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 6 ms 1488 KB Output is correct
12 Correct 8 ms 2128 KB Output is correct
13 Correct 8 ms 2076 KB Output is correct
14 Correct 8 ms 1904 KB Output is correct
15 Correct 28 ms 4728 KB Output is correct
16 Correct 27 ms 4824 KB Output is correct
17 Correct 23 ms 4868 KB Output is correct
18 Correct 26 ms 4424 KB Output is correct
19 Correct 31 ms 4936 KB Output is correct
20 Correct 29 ms 4912 KB Output is correct
21 Correct 24 ms 5012 KB Output is correct
22 Correct 30 ms 4680 KB Output is correct
23 Correct 29 ms 4968 KB Output is correct
24 Correct 24 ms 5004 KB Output is correct
25 Correct 24 ms 5128 KB Output is correct
26 Correct 27 ms 4736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 464 KB Output is correct
7 Correct 3 ms 720 KB Output is correct
8 Correct 4 ms 1232 KB Output is correct
9 Correct 8 ms 2000 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 6 ms 1488 KB Output is correct
12 Correct 8 ms 2128 KB Output is correct
13 Correct 8 ms 2076 KB Output is correct
14 Correct 8 ms 1904 KB Output is correct
15 Correct 28 ms 4728 KB Output is correct
16 Correct 27 ms 4824 KB Output is correct
17 Correct 23 ms 4868 KB Output is correct
18 Correct 26 ms 4424 KB Output is correct
19 Correct 31 ms 4936 KB Output is correct
20 Correct 29 ms 4912 KB Output is correct
21 Correct 24 ms 5012 KB Output is correct
22 Correct 30 ms 4680 KB Output is correct
23 Correct 29 ms 4968 KB Output is correct
24 Correct 24 ms 5004 KB Output is correct
25 Correct 24 ms 5128 KB Output is correct
26 Correct 27 ms 4736 KB Output is correct
27 Correct 28 ms 5108 KB Output is correct
28 Correct 33 ms 5148 KB Output is correct
29 Correct 25 ms 5228 KB Output is correct
30 Correct 31 ms 4924 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 464 KB Output is correct
7 Correct 3 ms 720 KB Output is correct
8 Correct 4 ms 1232 KB Output is correct
9 Correct 8 ms 2000 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 6 ms 1488 KB Output is correct
12 Correct 8 ms 2128 KB Output is correct
13 Correct 8 ms 2076 KB Output is correct
14 Correct 8 ms 1904 KB Output is correct
15 Correct 28 ms 4728 KB Output is correct
16 Correct 27 ms 4824 KB Output is correct
17 Correct 23 ms 4868 KB Output is correct
18 Correct 26 ms 4424 KB Output is correct
19 Correct 31 ms 4936 KB Output is correct
20 Correct 29 ms 4912 KB Output is correct
21 Correct 24 ms 5012 KB Output is correct
22 Correct 30 ms 4680 KB Output is correct
23 Correct 29 ms 4968 KB Output is correct
24 Correct 24 ms 5004 KB Output is correct
25 Correct 24 ms 5128 KB Output is correct
26 Correct 27 ms 4736 KB Output is correct
27 Correct 28 ms 5108 KB Output is correct
28 Correct 33 ms 5148 KB Output is correct
29 Correct 25 ms 5228 KB Output is correct
30 Correct 31 ms 4924 KB Output is correct
31 Correct 29 ms 5260 KB Output is correct
32 Correct 30 ms 5244 KB Output is correct
33 Correct 25 ms 5284 KB Output is correct
34 Correct 25 ms 4916 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 464 KB Output is correct
7 Correct 3 ms 720 KB Output is correct
8 Correct 4 ms 1232 KB Output is correct
9 Correct 8 ms 2000 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 6 ms 1488 KB Output is correct
12 Correct 8 ms 2128 KB Output is correct
13 Correct 8 ms 2076 KB Output is correct
14 Correct 8 ms 1904 KB Output is correct
15 Correct 28 ms 4728 KB Output is correct
16 Correct 27 ms 4824 KB Output is correct
17 Correct 23 ms 4868 KB Output is correct
18 Correct 26 ms 4424 KB Output is correct
19 Correct 31 ms 4936 KB Output is correct
20 Correct 29 ms 4912 KB Output is correct
21 Correct 24 ms 5012 KB Output is correct
22 Correct 30 ms 4680 KB Output is correct
23 Correct 29 ms 4968 KB Output is correct
24 Correct 24 ms 5004 KB Output is correct
25 Correct 24 ms 5128 KB Output is correct
26 Correct 27 ms 4736 KB Output is correct
27 Correct 28 ms 5108 KB Output is correct
28 Correct 33 ms 5148 KB Output is correct
29 Correct 25 ms 5228 KB Output is correct
30 Correct 31 ms 4924 KB Output is correct
31 Correct 29 ms 5260 KB Output is correct
32 Correct 30 ms 5244 KB Output is correct
33 Correct 25 ms 5284 KB Output is correct
34 Correct 25 ms 4916 KB Output is correct
35 Incorrect 26 ms 4996 KB Wrong Answer [2]
36 Halted 0 ms 0 KB -