Submission #908275

# Submission time Handle Problem Language Result Execution time Memory
908275 2024-01-16T10:49:09 Z zyq181 Coreputer (IOI23_coreputer) C++17
20 / 100
1 ms 344 KB
#include "coreputer.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> malfunctioning_cores(int N){
	vector<int> them;
	vector<int> q;
	int ret;
	int cur;
	for(int a=0; a<N; a+=2){
		q.push_back(a);
	}
	ret = run_diagnostic(q);
	if(ret == 1){
		int t;
		q.clear();
		for(int a=1; a<N; a+=2) q.push_back(a);
		for(int a=0; a<N; a+=2){
			q.push_back(a);
			t = run_diagnostic(q);
			if(t != -1){
				cur = a;
				them.push_back(a);
				break;
			}
		}
		for(int a=cur+2; a<N; a+=2){
			q.pop_back();
			q.push_back(a);
			if(run_diagnostic(q) != -1){
				them.push_back(a);
			}
		}
		int k = them.size();
		if(t == 0){
			k--;
		}
		q.clear();
		for(int a=0; a<k-1; a++){
			q.push_back(them[a]);
		}
		q.push_back(0);
		for(int a=1; a<N; a+=2){
			q.pop_back();
			q.push_back(a);
			if(run_diagnostic(q) != -1) them.push_back(a);
		}
	}
	else if(ret == -1){
		int t;
		for(int a=1; a<N; a+=2){
			q.push_back(a);
			t = run_diagnostic(q);
			if(t != -1){
				cur = a;
				them.push_back(a);
				break;
			}
		}
		for(int a=cur+2; a<N; a+=2){
			q.pop_back();
			q.push_back(a);
			if(run_diagnostic(q) != -1){
				them.push_back(a);
			}
		}
		int k = them.size();
		if(t == 0){
			k--;
		}
		q.clear();
		for(int a=0; a<k-1; a++){
			q.push_back(them[a]);
		}
		q.push_back(0);
		for(int a=0; a<N; a+=2){
			q.pop_back();
			q.push_back(a);
			if(run_diagnostic(q) != -1) them.push_back(a);
		}
	}
	else{
		q.push_back(1);
		for(int a=1; a<N; a+=2){
			q.pop_back();
			q.push_back(a);
			if(run_diagnostic(q) != 0) them.push_back(a);
		}
		int k = them.size();
		q.clear();
		for(int a=0; a<k-1; a++){
			q.push_back(them[a]);
		}
		q.push_back(0);
		for(int a=0; a<N; a+=2){
			q.pop_back();
			q.push_back(a);
			if(run_diagnostic(q) != -1) them.push_back(a);
		}
	}
	sort(them.begin(), them.end(), greater<int>());
	vector<int> r;
	for(int a=0; a<N; a++){
		if(them.back() == a){
			r.push_back(1);
			them.pop_back();
		}
		else{
			r.push_back(0);
		}
	}
	return r;
}

Compilation message

coreputer.cpp: In function 'std::vector<int> malfunctioning_cores(int)':
coreputer.cpp:27:16: warning: 'cur' may be used uninitialized in this function [-Wmaybe-uninitialized]
   27 |   for(int a=cur+2; a<N; a+=2){
      |             ~~~^~
# Verdict Execution time Memory Grader output
1 Correct 0 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 344 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 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 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 1 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 1 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 1 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Incorrect 1 ms 344 KB Incorrect
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 344 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 0 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 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 1 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 1 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 0 ms 344 KB Output is correct
27 Incorrect 1 ms 344 KB Incorrect
28 Halted 0 ms 0 KB -