Submission #517106

# Submission time Handle Problem Language Result Execution time Memory
517106 2022-01-22T14:20:53 Z lovrot Minerals (JOI19_minerals) C++14
80 / 100
52 ms 3388 KB
#include <bits/stdc++.h> 
#include "minerals.h"

#define pb push_back
#define vec vector
#define siz size()
using namespace std;

int n;	
int pref; 

/*
int query_ans;
bool on[100000];
map<int, int> ans_esp;
int Query(int x){
	int y = ans_esp[x]; 
		
	if(!on[x]){ 
		if(!on[y])
			query_ans++;
		on[x] = 1;
	}
	else{ 
		if(!on[y])
			query_ans--;
		on[x] = 0;
	}	
	return query_ans;
}
void Answer(int x, int y){ 
	if(ans_esp[x] == y)
		return;
	cout << "FAIL\n";
	exit(0);
} */

bool query(int x){ 
	int now = Query(x);
	bool ret = (now != pref);
	pref = now;
	return ret;
}

void solve(vec<int> x, vec<int> y, bool all_in){ 
	if(x.siz == 1){ 
		//cout << x[0] << " " << y[0] << "\n";
		Answer(x[0], y[0]);
		return;
	}

	vec<int> lx, rx;
	vec<int> ly, ry;
	int m = x.siz / 2;

	if(all_in){ 
		for(int i = 0; i < x.siz; i++){ 
			if(i < m){ 
				query(x[i]);		
				lx.pb(x[i]);				
			} else{ 
				rx.pb(x[i]);
			}
		}
	} else{ 
		for(int i = 0; i < x.siz; i++){ 
			if(i < m){ 
				query(x[i]);
				rx.pb(x[i]);
			} else
				lx.pb(x[i]);
		}
	}

	for(int i : y){ 
		if(query(i)) ly.pb(i);
		else  ry.pb(i);
	}
	/*
	for(int i : x)
		cout << i << " ";
	cout << "\n";
	for(int i : y)
		cout << i << " ";
	cout << "\n----------\n";
	*/
	solve(lx, ly, 0); 
	solve(rx, ry, 1);
}

void Solve(int N){ 
	n = N;

	vec<int> a;
	vec<int> b;

	for(int i = 1; i <= n * 2; i++){ 
		if(query(i)) a.pb(i);
		else b.pb(i);
	}

	solve(a, b, 1);
}

/*
int main(){ 	
	ios_base::sync_with_stdio(0);

	int n;

	cin >> n;

	for(int i = 0; i < n; i++){ 
		int x, y;
		cin >> x >> y;
		ans_esp[x] = y;
		ans_esp[y] = x;
	}

	Solve(n);

	cout << "Correct\n";

	return 0;
}*/

Compilation message

minerals.cpp: In function 'void solve(std::vector<int>, std::vector<int>, bool)':
minerals.cpp:57:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |   for(int i = 0; i < x.siz; i++){
      |                    ^
minerals.cpp:66:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |   for(int i = 0; i < x.siz; i++){
      |                    ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 2 ms 328 KB Output is correct
3 Correct 4 ms 576 KB Output is correct
4 Correct 6 ms 804 KB Output is correct
5 Correct 18 ms 1332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 328 KB Output is correct
7 Correct 4 ms 576 KB Output is correct
8 Correct 6 ms 804 KB Output is correct
9 Correct 18 ms 1332 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 9 ms 968 KB Output is correct
12 Correct 15 ms 1352 KB Output is correct
13 Correct 12 ms 1352 KB Output is correct
14 Correct 11 ms 1224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 328 KB Output is correct
7 Correct 4 ms 576 KB Output is correct
8 Correct 6 ms 804 KB Output is correct
9 Correct 18 ms 1332 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 9 ms 968 KB Output is correct
12 Correct 15 ms 1352 KB Output is correct
13 Correct 12 ms 1352 KB Output is correct
14 Correct 11 ms 1224 KB Output is correct
15 Correct 42 ms 3132 KB Output is correct
16 Correct 38 ms 3104 KB Output is correct
17 Correct 36 ms 3040 KB Output is correct
18 Correct 30 ms 2836 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 328 KB Output is correct
7 Correct 4 ms 576 KB Output is correct
8 Correct 6 ms 804 KB Output is correct
9 Correct 18 ms 1332 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 9 ms 968 KB Output is correct
12 Correct 15 ms 1352 KB Output is correct
13 Correct 12 ms 1352 KB Output is correct
14 Correct 11 ms 1224 KB Output is correct
15 Correct 42 ms 3132 KB Output is correct
16 Correct 38 ms 3104 KB Output is correct
17 Correct 36 ms 3040 KB Output is correct
18 Correct 30 ms 2836 KB Output is correct
19 Correct 44 ms 3220 KB Output is correct
20 Correct 44 ms 3268 KB Output is correct
21 Correct 31 ms 3088 KB Output is correct
22 Correct 32 ms 2996 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 328 KB Output is correct
7 Correct 4 ms 576 KB Output is correct
8 Correct 6 ms 804 KB Output is correct
9 Correct 18 ms 1332 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 9 ms 968 KB Output is correct
12 Correct 15 ms 1352 KB Output is correct
13 Correct 12 ms 1352 KB Output is correct
14 Correct 11 ms 1224 KB Output is correct
15 Correct 42 ms 3132 KB Output is correct
16 Correct 38 ms 3104 KB Output is correct
17 Correct 36 ms 3040 KB Output is correct
18 Correct 30 ms 2836 KB Output is correct
19 Correct 44 ms 3220 KB Output is correct
20 Correct 44 ms 3268 KB Output is correct
21 Correct 31 ms 3088 KB Output is correct
22 Correct 32 ms 2996 KB Output is correct
23 Correct 44 ms 3224 KB Output is correct
24 Correct 52 ms 3272 KB Output is correct
25 Correct 32 ms 3196 KB Output is correct
26 Correct 33 ms 3060 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 328 KB Output is correct
7 Correct 4 ms 576 KB Output is correct
8 Correct 6 ms 804 KB Output is correct
9 Correct 18 ms 1332 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 9 ms 968 KB Output is correct
12 Correct 15 ms 1352 KB Output is correct
13 Correct 12 ms 1352 KB Output is correct
14 Correct 11 ms 1224 KB Output is correct
15 Correct 42 ms 3132 KB Output is correct
16 Correct 38 ms 3104 KB Output is correct
17 Correct 36 ms 3040 KB Output is correct
18 Correct 30 ms 2836 KB Output is correct
19 Correct 44 ms 3220 KB Output is correct
20 Correct 44 ms 3268 KB Output is correct
21 Correct 31 ms 3088 KB Output is correct
22 Correct 32 ms 2996 KB Output is correct
23 Correct 44 ms 3224 KB Output is correct
24 Correct 52 ms 3272 KB Output is correct
25 Correct 32 ms 3196 KB Output is correct
26 Correct 33 ms 3060 KB Output is correct
27 Incorrect 45 ms 3388 KB Wrong Answer [2]
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 328 KB Output is correct
7 Correct 4 ms 576 KB Output is correct
8 Correct 6 ms 804 KB Output is correct
9 Correct 18 ms 1332 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 9 ms 968 KB Output is correct
12 Correct 15 ms 1352 KB Output is correct
13 Correct 12 ms 1352 KB Output is correct
14 Correct 11 ms 1224 KB Output is correct
15 Correct 42 ms 3132 KB Output is correct
16 Correct 38 ms 3104 KB Output is correct
17 Correct 36 ms 3040 KB Output is correct
18 Correct 30 ms 2836 KB Output is correct
19 Correct 44 ms 3220 KB Output is correct
20 Correct 44 ms 3268 KB Output is correct
21 Correct 31 ms 3088 KB Output is correct
22 Correct 32 ms 2996 KB Output is correct
23 Correct 44 ms 3224 KB Output is correct
24 Correct 52 ms 3272 KB Output is correct
25 Correct 32 ms 3196 KB Output is correct
26 Correct 33 ms 3060 KB Output is correct
27 Incorrect 45 ms 3388 KB Wrong Answer [2]
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 2 ms 328 KB Output is correct
7 Correct 4 ms 576 KB Output is correct
8 Correct 6 ms 804 KB Output is correct
9 Correct 18 ms 1332 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 9 ms 968 KB Output is correct
12 Correct 15 ms 1352 KB Output is correct
13 Correct 12 ms 1352 KB Output is correct
14 Correct 11 ms 1224 KB Output is correct
15 Correct 42 ms 3132 KB Output is correct
16 Correct 38 ms 3104 KB Output is correct
17 Correct 36 ms 3040 KB Output is correct
18 Correct 30 ms 2836 KB Output is correct
19 Correct 44 ms 3220 KB Output is correct
20 Correct 44 ms 3268 KB Output is correct
21 Correct 31 ms 3088 KB Output is correct
22 Correct 32 ms 2996 KB Output is correct
23 Correct 44 ms 3224 KB Output is correct
24 Correct 52 ms 3272 KB Output is correct
25 Correct 32 ms 3196 KB Output is correct
26 Correct 33 ms 3060 KB Output is correct
27 Incorrect 45 ms 3388 KB Wrong Answer [2]
28 Halted 0 ms 0 KB -