답안 #908259

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
908259 2024-01-16T10:39:54 Z zyq181 Coreputer (IOI23_coreputer) C++17
0 / 100
0 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) != ret){
				them.push_back(a);
			}
		}
		int k = them.size();
		if(t == 0){
			k--;
		}
		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{
		int t;
		for(int a=1; a<N; a+=2){
			q.push_back(a);
			t = run_diagnostic(q);
			if(t != ret){
				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) != ret){
				them.push_back(a);
			}
		}
		int k = them.size();
		if(ret == 0 || t == 0){
			k--;
		}
		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){
      |             ~~~^~
coreputer.cpp:67:20: warning: 't' may be used uninitialized in this function [-Wmaybe-uninitialized]
   67 |   if(ret == 0 || t == 0){
      |                  ~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB invalid array
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB invalid array
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB invalid array
2 Halted 0 ms 0 KB -