Submission #126367

# Submission time Handle Problem Language Result Execution time Memory
126367 2019-07-07T13:42:48 Z TadijaSebez Minerals (JOI19_minerals) C++14
100 / 100
75 ms 4280 KB
#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
void Solve(vector<int> l, vector<int> r, int in)
{
	if(l.size()==1)
	{
		Answer(l[0],r[0]);
		return;
	}
	int pre;
	vector<int> L[2],R[2];
	int sz=l.size()/3;
	if(l.size()==2) sz=1;
	for(int i=0;i<l.size();i++) L[i>=sz].pb(l[i]);
	for(int i:L[0]) pre=Query(i);
	for(int i:r)
	{
		if(L[0].size()==R[0].size()) R[1].pb(i);
		else if(L[1].size()==R[1].size()) R[0].pb(i);
		else
		{
			int now=Query(i);
			if(now==pre)
			{
				if(in) R[1].pb(i);
				else R[0].pb(i);
			}
			else
			{
				if(in) R[0].pb(i);
				else R[1].pb(i);
			}
			pre=now;
		}
	}
	Solve(L[0],R[0],in^1);
	Solve(L[1],R[1],in);
}
void Solve(int n)
{
	srand(time(0));
	vector<int> l,r;
	int pre=0;
	for(int i=1;i<=n*2;i++)
	{
		int now=Query(i);
		if(now!=pre) l.pb(i);
		else r.pb(i);
		pre=now;
	}
	Solve(l,r,1);
}

Compilation message

minerals.cpp: In function 'void Solve(std::vector<int>, std::vector<int>, int)':
minerals.cpp:16:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<l.size();i++) L[i>=sz].pb(l[i]);
              ~^~~~~~~~~
minerals.cpp:25:4: warning: 'pre' may be used uninitialized in this function [-Wmaybe-uninitialized]
    if(now==pre)
    ^~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 5 ms 508 KB Output is correct
3 Correct 8 ms 632 KB Output is correct
4 Correct 14 ms 1016 KB Output is correct
5 Correct 24 ms 1652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 5 ms 508 KB Output is correct
7 Correct 8 ms 632 KB Output is correct
8 Correct 14 ms 1016 KB Output is correct
9 Correct 24 ms 1652 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 17 ms 1228 KB Output is correct
12 Correct 24 ms 1728 KB Output is correct
13 Correct 19 ms 1800 KB Output is correct
14 Correct 20 ms 1732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 5 ms 508 KB Output is correct
7 Correct 8 ms 632 KB Output is correct
8 Correct 14 ms 1016 KB Output is correct
9 Correct 24 ms 1652 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 17 ms 1228 KB Output is correct
12 Correct 24 ms 1728 KB Output is correct
13 Correct 19 ms 1800 KB Output is correct
14 Correct 20 ms 1732 KB Output is correct
15 Correct 62 ms 3804 KB Output is correct
16 Correct 75 ms 3780 KB Output is correct
17 Correct 48 ms 3796 KB Output is correct
18 Correct 51 ms 3668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 5 ms 508 KB Output is correct
7 Correct 8 ms 632 KB Output is correct
8 Correct 14 ms 1016 KB Output is correct
9 Correct 24 ms 1652 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 17 ms 1228 KB Output is correct
12 Correct 24 ms 1728 KB Output is correct
13 Correct 19 ms 1800 KB Output is correct
14 Correct 20 ms 1732 KB Output is correct
15 Correct 62 ms 3804 KB Output is correct
16 Correct 75 ms 3780 KB Output is correct
17 Correct 48 ms 3796 KB Output is correct
18 Correct 51 ms 3668 KB Output is correct
19 Correct 64 ms 3856 KB Output is correct
20 Correct 69 ms 3880 KB Output is correct
21 Correct 51 ms 3912 KB Output is correct
22 Correct 51 ms 3688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 5 ms 508 KB Output is correct
7 Correct 8 ms 632 KB Output is correct
8 Correct 14 ms 1016 KB Output is correct
9 Correct 24 ms 1652 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 17 ms 1228 KB Output is correct
12 Correct 24 ms 1728 KB Output is correct
13 Correct 19 ms 1800 KB Output is correct
14 Correct 20 ms 1732 KB Output is correct
15 Correct 62 ms 3804 KB Output is correct
16 Correct 75 ms 3780 KB Output is correct
17 Correct 48 ms 3796 KB Output is correct
18 Correct 51 ms 3668 KB Output is correct
19 Correct 64 ms 3856 KB Output is correct
20 Correct 69 ms 3880 KB Output is correct
21 Correct 51 ms 3912 KB Output is correct
22 Correct 51 ms 3688 KB Output is correct
23 Correct 65 ms 4000 KB Output is correct
24 Correct 66 ms 4008 KB Output is correct
25 Correct 50 ms 4088 KB Output is correct
26 Correct 53 ms 3752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 5 ms 508 KB Output is correct
7 Correct 8 ms 632 KB Output is correct
8 Correct 14 ms 1016 KB Output is correct
9 Correct 24 ms 1652 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 17 ms 1228 KB Output is correct
12 Correct 24 ms 1728 KB Output is correct
13 Correct 19 ms 1800 KB Output is correct
14 Correct 20 ms 1732 KB Output is correct
15 Correct 62 ms 3804 KB Output is correct
16 Correct 75 ms 3780 KB Output is correct
17 Correct 48 ms 3796 KB Output is correct
18 Correct 51 ms 3668 KB Output is correct
19 Correct 64 ms 3856 KB Output is correct
20 Correct 69 ms 3880 KB Output is correct
21 Correct 51 ms 3912 KB Output is correct
22 Correct 51 ms 3688 KB Output is correct
23 Correct 65 ms 4000 KB Output is correct
24 Correct 66 ms 4008 KB Output is correct
25 Correct 50 ms 4088 KB Output is correct
26 Correct 53 ms 3752 KB Output is correct
27 Correct 68 ms 4112 KB Output is correct
28 Correct 68 ms 4164 KB Output is correct
29 Correct 52 ms 4072 KB Output is correct
30 Correct 54 ms 3860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 5 ms 508 KB Output is correct
7 Correct 8 ms 632 KB Output is correct
8 Correct 14 ms 1016 KB Output is correct
9 Correct 24 ms 1652 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 17 ms 1228 KB Output is correct
12 Correct 24 ms 1728 KB Output is correct
13 Correct 19 ms 1800 KB Output is correct
14 Correct 20 ms 1732 KB Output is correct
15 Correct 62 ms 3804 KB Output is correct
16 Correct 75 ms 3780 KB Output is correct
17 Correct 48 ms 3796 KB Output is correct
18 Correct 51 ms 3668 KB Output is correct
19 Correct 64 ms 3856 KB Output is correct
20 Correct 69 ms 3880 KB Output is correct
21 Correct 51 ms 3912 KB Output is correct
22 Correct 51 ms 3688 KB Output is correct
23 Correct 65 ms 4000 KB Output is correct
24 Correct 66 ms 4008 KB Output is correct
25 Correct 50 ms 4088 KB Output is correct
26 Correct 53 ms 3752 KB Output is correct
27 Correct 68 ms 4112 KB Output is correct
28 Correct 68 ms 4164 KB Output is correct
29 Correct 52 ms 4072 KB Output is correct
30 Correct 54 ms 3860 KB Output is correct
31 Correct 70 ms 4252 KB Output is correct
32 Correct 70 ms 4192 KB Output is correct
33 Correct 52 ms 4184 KB Output is correct
34 Correct 56 ms 4116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 248 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 5 ms 508 KB Output is correct
7 Correct 8 ms 632 KB Output is correct
8 Correct 14 ms 1016 KB Output is correct
9 Correct 24 ms 1652 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 17 ms 1228 KB Output is correct
12 Correct 24 ms 1728 KB Output is correct
13 Correct 19 ms 1800 KB Output is correct
14 Correct 20 ms 1732 KB Output is correct
15 Correct 62 ms 3804 KB Output is correct
16 Correct 75 ms 3780 KB Output is correct
17 Correct 48 ms 3796 KB Output is correct
18 Correct 51 ms 3668 KB Output is correct
19 Correct 64 ms 3856 KB Output is correct
20 Correct 69 ms 3880 KB Output is correct
21 Correct 51 ms 3912 KB Output is correct
22 Correct 51 ms 3688 KB Output is correct
23 Correct 65 ms 4000 KB Output is correct
24 Correct 66 ms 4008 KB Output is correct
25 Correct 50 ms 4088 KB Output is correct
26 Correct 53 ms 3752 KB Output is correct
27 Correct 68 ms 4112 KB Output is correct
28 Correct 68 ms 4164 KB Output is correct
29 Correct 52 ms 4072 KB Output is correct
30 Correct 54 ms 3860 KB Output is correct
31 Correct 70 ms 4252 KB Output is correct
32 Correct 70 ms 4192 KB Output is correct
33 Correct 52 ms 4184 KB Output is correct
34 Correct 56 ms 4116 KB Output is correct
35 Correct 71 ms 4280 KB Output is correct
36 Correct 71 ms 4244 KB Output is correct
37 Correct 54 ms 4244 KB Output is correct
38 Correct 56 ms 4072 KB Output is correct