답안 #985372

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
985372 2024-05-17T17:06:32 Z SzymonKrzywda 동굴 (IOI13_cave) C++17
0 / 100
33 ms 348 KB
#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],S[N],w=0,w_2=0;
    bool good[N];
    //int S_2[N];
    // 0 0 0 0 0
    // 1 1 1 1 1
    // 1 1 1 1 0
 
    //1110
    //3102
    
    
    for (int i=0; i<N; i++){
        w = tryCombination(S);
        //cout << i << "  "<<  w << endl;
        if(w==-1) break;
        if (w > i) continue;
        
        for (int j=0; j<N; j++){
            if (good[j]) continue;
            S[j] = (S[j]+1)%2;
            w_2 = tryCombination(S);
            if (w_2 < w) good[j] = true;
            w = w_2;
            //cout << i << " " << w << endl;
            if(w==-1) break;
            if (w>i) break;
            S[j] = (S[j]+1)%2;
        }
    }
    
    for (int i=0; i<N; i++){
            S[i] = (S[i]+1)%2;
            D[i] = tryCombination(S);
            S[i] = (S[i]+1)%2;
        }
    answer(S,D);
    
    
    /*
    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);
    }
    */
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 33 ms 344 KB too much calls on tryCombination()
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 7 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 0 ms 344 KB Answer is wrong
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Answer is wrong
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Answer is wrong
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 33 ms 344 KB too much calls on tryCombination()
2 Halted 0 ms 0 KB -