이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include"cave.h"
#include <bits/stdc++.h>
using namespace std;
int tryCombination(int S[]);
void answer(int S[],int D[]);
void exploreCave(int N){
int D[N];
//int S_2[N];
// 0 0 0 0 0
// 1 1 1 1 1
// 1 1 1 1 0
//1110
//3102
int S_1[N];
int S_2[N];
for (int i=0; i<N; i++) S_2[i] = 1;
bool good[N];
int do_zmiany[N];
for (int i=0; i<N; i++) do_zmiany[i] = -1;
int w = 0,akt=0,w_2=0,ktory=0;
while (w != -1){
if (akt == 0){
w = tryCombination(S_1);
if (w == -1){
ktory = 0;
break;
}
for (int i=0; i<N; i++){
if (!good[i]){
S_1[i] = 1;
w_2 = tryCombination(S_1);
if (w_2 == -1){
w = -1;
ktory = 0;
break;
}
if (w_2 < w){
S_2[i] = 0;
S_1[i] = 0;
good[i] = true;
D[i] = w_2;
w = tryCombination(S_1);
}
else if(w_2 > w){
good[i] = true;
D[i] = w;
w = w_2;
}
else S_1[i] = 0;
}
}
}
else{
w = tryCombination(S_2);
if (w == -1){
ktory = 1;
break;
}
for (int i=0; i<N; i++){
if (!good[i]){
S_2[i] = 0;
w_2 = tryCombination(S_2);
if (w_2 == -1){
w = -1;
ktory = 1;
break;
}
if (w_2 < w){
S_2[i] = 1;
S_1[i] = 1;
good[i] = true;
D[i] = w_2;
w = tryCombination(S_2);
}
else if(w_2 > w){
good[i] = true;
D[i] = w;
w = w_2;
}
else S_2[i] = 1;
}
}
}
akt = (akt+1)%2;
//cout << good[0] << endl;
//cout << w << endl;
//cout << "GOOD: ";
//for (int i=0; i<N; i++) cout << good[i] << " ";
//cout << endl;
}
if (ktory == 0){
for (int i=0; i<N; i++){
S_1[i] = (S_1[i]+1)%2;
if (!good[i]){
D[i] = tryCombination(S_1);
}
S_1[i] = (S_1[i]+1)%2;
}
answer(S_1,D);
}
else{
for (int i=0; i<N; i++){
S_2[i] = (S_2[i]+1)%2;
if (!good[i]){
D[i] = tryCombination(S_2);
}
S_2[i] = (S_2[i]+1)%2;
}
answer(S_2,D);
}
}
컴파일 시 표준 에러 (stderr) 메시지
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:24:9: warning: variable 'do_zmiany' set but not used [-Wunused-but-set-variable]
24 | int do_zmiany[N];
| ^~~~~~~~~
# | 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... |