Submission #908244

# Submission time Handle Problem Language Result Execution time Memory
908244 2024-01-16T10:14:47 Z zyq181 Coreputer (IOI23_coreputer) C++17
0 / 100
0 ms 380 KB
#include "coreputer.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> malfunctioning_cores(int N){
	int num;
	vector<int> them;
	int cur;
	bool flag = false;
	int ret;
	vector<int> q;
	for(int a=1; a<=N; a++){
		cur = a-1;
		q.push_back(a-1);
		ret = run_diagnostic(q);
		if(ret != -1){
			them.push_back(cur);
			flag = true;
			break;
		}
	}
	for(int a=cur+1; a<N; a++){
		q.pop_back();
		q.push_back(a);
		if(run_diagnostic(q) != -1){
			them.push_back(a);
		}
	}
	int cmp = them.size(); //either half + 1 or half + 1/2
	int k;
	if(ret == 1){
		num = cmp + cmp - 1; //cmp - 1
		k = cmp;
	}
	else{
		num = 2 * cmp - 2; //cmp - 2
		k = cmp - 1;
	}
	q.clear();
	for(int a=0; a<k; a++){	
		q.push_back(them[a]);
	}
	for(int a=0; a<cur; a++){
		q.pop_back();
		q.push_back(a);
		if(run_diagnostic(q) != -1){
			them.push_back(a);
		}
	}
	return q;
}

Compilation message

coreputer.cpp: In function 'std::vector<int> malfunctioning_cores(int)':
coreputer.cpp:6:6: warning: variable 'num' set but not used [-Wunused-but-set-variable]
    6 |  int num;
      |      ^~~
coreputer.cpp:9:7: warning: variable 'flag' set but not used [-Wunused-but-set-variable]
    9 |  bool flag = false;
      |       ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 380 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -