제출 #909907

#제출 시각아이디문제언어결과실행 시간메모리
909907PlayVoltzCoreputer (IOI23_coreputer)C++17
80 / 100
1 ms596 KiB
#include "coreputer.h"
#include <bits/stdc++.h>
using namespace std;

#define pb push_back

vector<int> malfunctioning_cores(int n){
	vector<int> c(n, 0), vect;
	int low=-1, high=n, end;
	while (low+1<high){
		int mid=(low+high)/2;
		vect.clear();
		for (int i=0; i<=mid; ++i)vect.pb(i);
		int res=run_diagnostic(vect);
		if (res>=0)high=mid, end=res;
		else low=mid;
	}
	c[high]=1;
	for (int i=0; i<high; ++i){
		vect.clear();
		for (int j=0; j<=high; ++j)if (i!=j)vect.pb(j);
		if (run_diagnostic(vect)<0)c[i]=1;
	}
	if (end){
		for (int i=high+1; i<n; ++i){
			vect.clear();
			for (int j=high; j<n; ++j)if (i!=j)vect.pb(j);
			if (run_diagnostic(vect)<0)c[i]=1;
		}
	}
	else{
		for (int i=high+1; i<n; ++i){
			vect.clear();
			for (int j=high+1; j<n; ++j)if (i!=j)vect.pb(j);
			if (run_diagnostic(vect)<0)c[i]=1;
		}
	}
	return c;
}

컴파일 시 표준 에러 (stderr) 메시지

coreputer.cpp: In function 'std::vector<int> malfunctioning_cores(int)':
coreputer.cpp:24:2: warning: 'end' may be used uninitialized in this function [-Wmaybe-uninitialized]
   24 |  if (end){
      |  ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...