Submission #710566

# Submission time Handle Problem Language Result Execution time Memory
710566 2023-03-15T11:10:44 Z LittleCube Minerals (JOI19_minerals) C++14
90 / 100
58 ms 3440 KB
#include "minerals.h"
#include <bits/stdc++.h>
#define pii pair<int, int>
#define F first
#define S second
using namespace std;

int pre, cur;

bool change(int x)
{
	// cerr << "change " << x << '\n';
	cur = Query(x);
	swap(pre, cur);
	return pre != cur;
}

void solve(vector<int> X, vector<int> Y, bool bX, bool bY)
{	
	if(X.size() == 1)
	{
		Answer(X[0], Y[0]);
		return;
	}
	int N = X.size(), mid = N / 2;

	vector<int> lX(X.begin(), X.begin() + mid), rX(X.begin() + mid, X.end()), lY, rY;

	if(bX)
		for(int i = mid; i < N; i++)
			change(X[i]);
	else
		for(int i = 0; i < mid; i++)
			change(X[i]);

	for(int i : Y)
	{		
		if(change(i))
			rY.emplace_back(i);
		else 
			lY.emplace_back(i);
		if(lY.size() == mid || rY.size() == N - mid)
			break;
	}
	if(lY.size() == mid)
		while(rY.size() < N - mid)
		{
			rY.emplace_back(Y.back());
			Y.pop_back();
		}
	else
		while(lY.size() < mid)
		{
			lY.emplace_back(Y.back());
			Y.pop_back();
		}

	solve(lX, lY, 1, !bY);
	solve(rX, rY, 0, !bY);

}

void Solve(int N)
{
	pre = cur = 0;
	vector<int> X, Y;

	mt19937 rd(std::chrono::steady_clock::now().time_since_epoch().count());

	for(int i = 1; i <= 2 * N; i++)
	{
		if(change(i))
			X.emplace_back(i);
		else
			Y.emplace_back(i);
	}
	shuffle(X.begin(), X.end(), rd);
	shuffle(Y.begin(), Y.end(), rd);
	solve(X, Y, 1, 1);
}

Compilation message

minerals.cpp: In function 'void solve(std::vector<int>, std::vector<int>, bool, bool)':
minerals.cpp:42:16: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   42 |   if(lY.size() == mid || rY.size() == N - mid)
      |      ~~~~~~~~~~^~~~~~
minerals.cpp:42:36: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   42 |   if(lY.size() == mid || rY.size() == N - mid)
      |                          ~~~~~~~~~~^~~~~~~~~~
minerals.cpp:45:15: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   45 |  if(lY.size() == mid)
      |     ~~~~~~~~~~^~~~~~
minerals.cpp:46:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   46 |   while(rY.size() < N - mid)
      |         ~~~~~~~~~~^~~~~~~~~
minerals.cpp:52:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   52 |   while(lY.size() < mid)
      |         ~~~~~~~~~~^~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 2 ms 336 KB Output is correct
3 Correct 4 ms 464 KB Output is correct
4 Correct 7 ms 748 KB Output is correct
5 Correct 14 ms 1232 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 2 ms 336 KB Output is correct
7 Correct 4 ms 464 KB Output is correct
8 Correct 7 ms 748 KB Output is correct
9 Correct 14 ms 1232 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 10 ms 1016 KB Output is correct
12 Correct 18 ms 1332 KB Output is correct
13 Correct 21 ms 1384 KB Output is correct
14 Correct 17 ms 1392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 2 ms 336 KB Output is correct
7 Correct 4 ms 464 KB Output is correct
8 Correct 7 ms 748 KB Output is correct
9 Correct 14 ms 1232 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 10 ms 1016 KB Output is correct
12 Correct 18 ms 1332 KB Output is correct
13 Correct 21 ms 1384 KB Output is correct
14 Correct 17 ms 1392 KB Output is correct
15 Correct 42 ms 3056 KB Output is correct
16 Correct 40 ms 3108 KB Output is correct
17 Correct 46 ms 3000 KB Output is correct
18 Correct 47 ms 2912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 2 ms 336 KB Output is correct
7 Correct 4 ms 464 KB Output is correct
8 Correct 7 ms 748 KB Output is correct
9 Correct 14 ms 1232 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 10 ms 1016 KB Output is correct
12 Correct 18 ms 1332 KB Output is correct
13 Correct 21 ms 1384 KB Output is correct
14 Correct 17 ms 1392 KB Output is correct
15 Correct 42 ms 3056 KB Output is correct
16 Correct 40 ms 3108 KB Output is correct
17 Correct 46 ms 3000 KB Output is correct
18 Correct 47 ms 2912 KB Output is correct
19 Correct 45 ms 3160 KB Output is correct
20 Correct 47 ms 3164 KB Output is correct
21 Correct 47 ms 3184 KB Output is correct
22 Correct 42 ms 3036 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 2 ms 336 KB Output is correct
7 Correct 4 ms 464 KB Output is correct
8 Correct 7 ms 748 KB Output is correct
9 Correct 14 ms 1232 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 10 ms 1016 KB Output is correct
12 Correct 18 ms 1332 KB Output is correct
13 Correct 21 ms 1384 KB Output is correct
14 Correct 17 ms 1392 KB Output is correct
15 Correct 42 ms 3056 KB Output is correct
16 Correct 40 ms 3108 KB Output is correct
17 Correct 46 ms 3000 KB Output is correct
18 Correct 47 ms 2912 KB Output is correct
19 Correct 45 ms 3160 KB Output is correct
20 Correct 47 ms 3164 KB Output is correct
21 Correct 47 ms 3184 KB Output is correct
22 Correct 42 ms 3036 KB Output is correct
23 Correct 46 ms 3156 KB Output is correct
24 Correct 49 ms 3272 KB Output is correct
25 Correct 58 ms 3148 KB Output is correct
26 Correct 49 ms 3204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 2 ms 336 KB Output is correct
7 Correct 4 ms 464 KB Output is correct
8 Correct 7 ms 748 KB Output is correct
9 Correct 14 ms 1232 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 10 ms 1016 KB Output is correct
12 Correct 18 ms 1332 KB Output is correct
13 Correct 21 ms 1384 KB Output is correct
14 Correct 17 ms 1392 KB Output is correct
15 Correct 42 ms 3056 KB Output is correct
16 Correct 40 ms 3108 KB Output is correct
17 Correct 46 ms 3000 KB Output is correct
18 Correct 47 ms 2912 KB Output is correct
19 Correct 45 ms 3160 KB Output is correct
20 Correct 47 ms 3164 KB Output is correct
21 Correct 47 ms 3184 KB Output is correct
22 Correct 42 ms 3036 KB Output is correct
23 Correct 46 ms 3156 KB Output is correct
24 Correct 49 ms 3272 KB Output is correct
25 Correct 58 ms 3148 KB Output is correct
26 Correct 49 ms 3204 KB Output is correct
27 Correct 48 ms 3292 KB Output is correct
28 Correct 48 ms 3272 KB Output is correct
29 Correct 51 ms 3284 KB Output is correct
30 Correct 46 ms 3064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 2 ms 336 KB Output is correct
7 Correct 4 ms 464 KB Output is correct
8 Correct 7 ms 748 KB Output is correct
9 Correct 14 ms 1232 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 10 ms 1016 KB Output is correct
12 Correct 18 ms 1332 KB Output is correct
13 Correct 21 ms 1384 KB Output is correct
14 Correct 17 ms 1392 KB Output is correct
15 Correct 42 ms 3056 KB Output is correct
16 Correct 40 ms 3108 KB Output is correct
17 Correct 46 ms 3000 KB Output is correct
18 Correct 47 ms 2912 KB Output is correct
19 Correct 45 ms 3160 KB Output is correct
20 Correct 47 ms 3164 KB Output is correct
21 Correct 47 ms 3184 KB Output is correct
22 Correct 42 ms 3036 KB Output is correct
23 Correct 46 ms 3156 KB Output is correct
24 Correct 49 ms 3272 KB Output is correct
25 Correct 58 ms 3148 KB Output is correct
26 Correct 49 ms 3204 KB Output is correct
27 Correct 48 ms 3292 KB Output is correct
28 Correct 48 ms 3272 KB Output is correct
29 Correct 51 ms 3284 KB Output is correct
30 Correct 46 ms 3064 KB Output is correct
31 Correct 50 ms 3440 KB Output is correct
32 Correct 49 ms 3392 KB Output is correct
33 Correct 45 ms 3268 KB Output is correct
34 Correct 45 ms 3300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 2 ms 336 KB Output is correct
7 Correct 4 ms 464 KB Output is correct
8 Correct 7 ms 748 KB Output is correct
9 Correct 14 ms 1232 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 10 ms 1016 KB Output is correct
12 Correct 18 ms 1332 KB Output is correct
13 Correct 21 ms 1384 KB Output is correct
14 Correct 17 ms 1392 KB Output is correct
15 Correct 42 ms 3056 KB Output is correct
16 Correct 40 ms 3108 KB Output is correct
17 Correct 46 ms 3000 KB Output is correct
18 Correct 47 ms 2912 KB Output is correct
19 Correct 45 ms 3160 KB Output is correct
20 Correct 47 ms 3164 KB Output is correct
21 Correct 47 ms 3184 KB Output is correct
22 Correct 42 ms 3036 KB Output is correct
23 Correct 46 ms 3156 KB Output is correct
24 Correct 49 ms 3272 KB Output is correct
25 Correct 58 ms 3148 KB Output is correct
26 Correct 49 ms 3204 KB Output is correct
27 Correct 48 ms 3292 KB Output is correct
28 Correct 48 ms 3272 KB Output is correct
29 Correct 51 ms 3284 KB Output is correct
30 Correct 46 ms 3064 KB Output is correct
31 Correct 50 ms 3440 KB Output is correct
32 Correct 49 ms 3392 KB Output is correct
33 Correct 45 ms 3268 KB Output is correct
34 Correct 45 ms 3300 KB Output is correct
35 Incorrect 53 ms 3316 KB Wrong Answer [2]
36 Halted 0 ms 0 KB -