Submission #908317

# Submission time Handle Problem Language Result Execution time Memory
908317 2024-01-16T11:05:40 Z shoryu386 Coreputer (IOI23_coreputer) C++17
50 / 100
1 ms 600 KB
#include "coreputer.h"
#include <bits/stdc++.h>
using namespace std;


vector<int> ntwo(){
	int res = run_diagnostic({0});
	
	if (res == 1){
		return {1, 0};
	}
	else if (res == 0){
		int any = run_diagnostic({0, 1});
		
		if (any == 0){
			return {0, 0};
		}
		else return {1, 1};
	}
	else return {0, 1};
}

vector<int> malfunctioning_cores(int N) {
	if (N == 2){
		return ntwo();
	}
	
	int firstZero = -1, lastZero = -1;
	
	
	int l = 0, r = N-1;
	while (l <= r){
		int m = (l+r)/2;
		
		vector<int> bruh;
		for (int y = 0; y <= m; y++) bruh.push_back(y);
		
		int res = run_diagnostic(bruh);
		
		
		//cerr << m << ' ' << run_diagnostic(bruh) << "???\n" ;
		
		if (res == 1){
			r = m-1;
		}
		else if (res == 0){
			r = m-1;
			firstZero = m;
		}
		else{
			l = m+1;
		}
	}
	
	l = 0, r = N-1;
	while (l <= r){
		int m = (l+r)/2;
		
		vector<int> bruh;
		for (int y = 0; y <= m; y++) bruh.push_back(y);
		
		int res = run_diagnostic(bruh);
		
		//cerr << m << ' ' << run_diagnostic(bruh) << "???\n" ;
		
		if (res == -1){
			l = m+1;
		}
		else if (res == 0){
			l = m+1;
			lastZero = m;
		}
		else{
			r = m-1;
		}
	}
	
	
	assert(lastZero != -1); //even case
	assert(firstZero != -1);
	
	//cerr << firstZero << ' ' << lastZero << '\n';
	
	//our malfunctions are at firstZero, and lastZero+1
	//we also now know that there are an equal number of malfunctions in the two segments [0, firstZero-1] and [lastZero+2, 15]
	
	vector<int> ans(N, 0);
	ans[firstZero] = 1;
	ans[lastZero+1] = 1;
	
	for (int x = N-1; x > lastZero+1; x--){
		//include [0, firstZero], include [lastZero+1, 15], except one element
		
		vector<int> cur;
		
		#define ADDRANGE(a, b) for (int y = a; y <= b; y++) cur.push_back(y); 
		
		ADDRANGE(0, firstZero);
		//ADDRANGE(lastZero+1, 15);
		
		//cur.erase(find(cur.begin(), cur.end(), x));
		ADDRANGE(x, x);
		
		int res = run_diagnostic(cur);
		
		//cerr << "\n run: \n";
		//for (auto y : cur) cerr << y << ' ';
		//cerr << '\n';
		//cerr << res << '\n';
		
		if (res == 0){
			ans[x] = 0;
		}
		else ans[x] = 1;
	}
	
	for (int x = 0; x < firstZero; x++){
		//include [0, firstZero], exclude [lastZero+1, 15], except one element
		vector<int> cur;
		
		#define ADDRANGE(a, b) for (int y = a; y <= b; y++) cur.push_back(y); 
		
		//ADDRANGE(0, firstZero);
		ADDRANGE(lastZero+1, N-1);
		
		ADDRANGE(x, x);
		//cur.erase(find(cur.begin(), cur.end(), x));
		
		int res = run_diagnostic(cur);
		
		if (res == 0){
			ans[x] = 0;
		}
		else ans[x] = 1;
	}
	
	return ans;
	
	
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 428 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Partially correct 1 ms 344 KB Output is partially correct
21 Partially correct 0 ms 596 KB Output is partially correct
22 Partially correct 0 ms 344 KB Output is partially correct
23 Partially correct 0 ms 344 KB Output is partially correct
24 Partially correct 0 ms 344 KB Output is partially correct
25 Partially correct 1 ms 344 KB Output is partially correct
26 Partially correct 0 ms 344 KB Output is partially correct
27 Partially correct 1 ms 344 KB Output is partially correct
28 Partially correct 1 ms 540 KB Output is partially correct
29 Partially correct 1 ms 344 KB Output is partially correct
30 Partially correct 0 ms 344 KB Output is partially correct
31 Partially correct 1 ms 344 KB Output is partially correct
32 Partially correct 1 ms 344 KB Output is partially correct
33 Partially correct 0 ms 344 KB Output is partially correct
34 Partially correct 0 ms 344 KB Output is partially correct
35 Partially correct 1 ms 344 KB Output is partially correct
36 Partially correct 1 ms 344 KB Output is partially correct
37 Partially correct 0 ms 344 KB Output is partially correct
38 Partially correct 0 ms 344 KB Output is partially correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 428 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Partially correct 1 ms 344 KB Output is partially correct
24 Partially correct 0 ms 596 KB Output is partially correct
25 Partially correct 0 ms 344 KB Output is partially correct
26 Partially correct 0 ms 344 KB Output is partially correct
27 Partially correct 0 ms 344 KB Output is partially correct
28 Partially correct 1 ms 344 KB Output is partially correct
29 Partially correct 0 ms 344 KB Output is partially correct
30 Partially correct 1 ms 344 KB Output is partially correct
31 Partially correct 1 ms 540 KB Output is partially correct
32 Partially correct 1 ms 344 KB Output is partially correct
33 Partially correct 0 ms 344 KB Output is partially correct
34 Partially correct 1 ms 344 KB Output is partially correct
35 Partially correct 1 ms 344 KB Output is partially correct
36 Partially correct 0 ms 344 KB Output is partially correct
37 Partially correct 0 ms 344 KB Output is partially correct
38 Partially correct 1 ms 344 KB Output is partially correct
39 Partially correct 1 ms 344 KB Output is partially correct
40 Partially correct 0 ms 344 KB Output is partially correct
41 Partially correct 0 ms 344 KB Output is partially correct
42 Runtime error 1 ms 600 KB Execution killed with signal 6
43 Halted 0 ms 0 KB -