이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "cave.h"
#include <bits/stdc++.h>
using namespace std;
void exploreCave(int N) {
int which_switch[N], how_switch[N], used[N], used_ans[N], used_for[N];
memset(which_switch, 0, sizeof(which_switch));
memset(how_switch, 0, sizeof(how_switch));
memset(used, 0, sizeof(used));
memset(used_ans, 0, sizeof(used_ans));
memset(used_for, 0, sizeof(used_for));
for(int i=0;i<N;i++){
vector <int> p, np;
int v[N];
memset(v, 0, sizeof(v));
for(int j=0;j<N;j++){
if(!used[j])p.push_back(j);
else np.push_back(j);
}
int l=0, r=p.size()-1, mid;
for(int j=0;j<np.size();j++)v[np[j]]=used_ans[np[j]];
for(int j=0;j<p.size();j++)v[p[j]]=0;
int res=tryCombination(v);
if(res==i)how_switch[i]=1;
else how_switch[i]=0;
while(l<r){
mid=(l+r)/2;
for(int j=0;j<np.size();j++)v[np[j]]=used_ans[np[j]];
for(int j=0;j<=mid;j++)v[p[j]]=how_switch[i];
for(int j=mid+1;j<p.size();j++)v[p[j]]=1-how_switch[i];
int res=tryCombination(v);
if(res==i)l=mid+1;
else r=mid;
}
which_switch[i]=l;
used_ans[l]=how_switch[i];
used_for[l]=i;
}
answer(used_for, used_ans);
}
컴파일 시 표준 에러 (stderr) 메시지
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:22:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0;j<np.size();j++)v[np[j]]=used_ans[np[j]];
~^~~~~~~~~~
cave.cpp:23:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0;j<p.size();j++)v[p[j]]=0;
~^~~~~~~~~
cave.cpp:30:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0;j<np.size();j++)v[np[j]]=used_ans[np[j]];
~^~~~~~~~~~
cave.cpp:32:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=mid+1;j<p.size();j++)v[p[j]]=1-how_switch[i];
~^~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |