Submission #1344839

#TimeUsernameProblemLanguageResultExecution timeMemory
1344839nanaseyuzukiCave (IOI13_cave)C++20
33 / 100
20 ms536 KiB
#include <bits/stdc++.h>
#include "cave.h"
#define ll long long
#define fi first
#define se second
#define pii pair<int, int>
#define all(a) a.begin(), a.end()
using namespace std;

#ifdef LOCAL
#include "C:\Users\Dell\Downloads\template\template\icpc-notebook\Utilities\debug.h"
#else
#define debug(...) 42
#endif

const int mn = 5e5 + 5, mod = 1e9 + 7, inf = 2e9;

void exploreCave(int n) {
    int s[n] = {0}, d[n] = {0}, on[n] = {0}, c[n];

    for(int i = 0; i < n; i++) {
        int all = tryCombination(s);
        // for(int i = 0; i < n; i++) cout << s[i] << ' ';
        // cout << '\n';
        // cout << "All " << all << '\n';
        if(all == i) {
            for(int j = 0; j < n; j++) {
                if(on[j]) continue;
                s[j] ^= 1;
                int cur = tryCombination(s);
                if(cur != i) {
                    c[i] = j;
                    break;
                }
            }
            
            for(int j = 0; j < c[i]; j++) {
                if(on[j]) continue;
                s[j] ^= 1;
            } 
        }
        else if(all != i) {
            for(int j = 0; j < n; j++) {
                if(on[j]) continue;
                s[j] ^= 1;
                int cur = tryCombination(s);
                if(cur == i) {
                    c[i] = j;
                    break;
                }
            }
            
            for(int j = 0; j <= c[i]; j++) {
                if(on[j]) continue;
                s[j] ^= 1;
            }
        }
        d[c[i]] = i;
        // cout << "c[i] = " << c[i] << '\n';
        on[c[i]] = 1;
    }

    answer(s, d);
}
// Don't wanna lose anymore T_T
// Never let me go - Kazuo Ishiguro
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...