Submission #583576

# Submission time Handle Problem Language Result Execution time Memory
583576 2022-06-25T15:44:34 Z kirill_iceland Cave (IOI13_cave) C++14
0 / 100
75 ms 65536 KB
#include "cave.h"
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(__typeof(a) i = a; a < b; i++)
typedef pair<int, int> ii;
typedef vector<int> vi;

void exploreCave(int n){
    srand(2801043610);
    int swiches[n];
    memset(swiches, 0, sizeof(swiches));
    vi swiches2;
    int connections[n]; // swich --> door
    memset(connections, -1, sizeof(connections));

    rep(i, 0, n){
        swiches2.push_back(i);
    }

    int pr = rand() % swiches2.size();
    int pswich = swiches2[pr];
    swiches[pswich] = 1 - swiches[pswich];
    int pres = tryCombination(swiches);
    while(true){
        int r = rand() % swiches2.size();
        int swich = swiches2[r];
        swiches[swich] = 1 - swiches[swich];
        int res = tryCombination(swiches);
        if(pres == -1){
            connections[swich] = res;
            swiches[swich] = 1 - swiches[swich]; //open door
            swiches2.erase(swiches2.begin() + r);
            res = pres; 
            r = pr;
        }else if(res == -1){
            connections[swich] = pres;
            swiches2.erase(swiches2.begin() + pr);
        }else if(pres < res){ //door opened
            connections[swich] = pres;
            swiches2.erase(swiches2.begin() + pr);
        }else if(pres > res){ //door closed
            connections[swich] = res;
            swiches[swich] = 1 - swiches[swich]; //open door
            swiches2.erase(swiches2.begin() + r);
            res = pres; 
            r = pr; 
        }
        
        if(swiches2.size() == 0){
            answer(swiches, connections);
            return;
        }
        pswich = swich;
        pr = r;
    }
}
# Verdict Execution time Memory Grader output
1 Runtime error 72 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 75 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 71 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 71 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 72 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -