Submission #156815

# Submission time Handle Problem Language Result Execution time Memory
156815 2019-10-07T14:54:26 Z popovicirobert Minerals (JOI19_minerals) C++14
25 / 100
12 ms 824 KB
#include "minerals.h"
#include <bits/stdc++.h>

using namespace std;

void Solve(int n) {
	vector <int> sol(2 * n);
	vector <bool> in(2 * n);
	int i;
  	for(int bit = 15; bit >= 0; bit--) {
		if((1 << bit) >= n) continue;
		int ans;
		for(i = 0; i < n; i++) {
			if(i & (1 << bit)) {
				if(in[i]) continue;
				ans = Query(i + 1);
				in[i] = 1;
			}
		}
		for(i = n; i < 2 * n; i++) {
			if(Query(i + 1) == ans) {
				sol[i] += (1 << bit);
			}
			Query(i + 1);
		}
		for(i = 0; i < n; i++) {
			if(bit == 0) continue;
			if(i & (1 << bit)) {
				if(i & (1 << (bit - 1))) continue;
				Query(i + 1);
				in[i] = 0;
			}
		}
	}
	
	vector <bool> vis(2 * n);
	for(i = n; i < 2 * n; i++) {
		if(vis[i] == 0) {
			vis[i] = vis[sol[i]] = 1;
			Answer(i + 1, sol[i] + 1);
		}
	}
}

Compilation message

minerals.cpp: In function 'void Solve(int)':
minerals.cpp:21:4: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
    if(Query(i + 1) == ans) {
    ^~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 4 ms 376 KB Output is correct
4 Correct 7 ms 504 KB Output is correct
5 Correct 12 ms 824 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -