Submission #809204

# Submission time Handle Problem Language Result Execution time Memory
809204 2023-08-05T21:25:51 Z Boomyday Cave (IOI13_cave) C++14
100 / 100
645 ms 716 KB

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using db = double;
using str = string; // yay python!

using ii = pair<int,int>;
using pl = pair<ll,ll>;
using pd = pair<db,db>;

using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<ll>;
using vd = vector<db>;
using vs = vector<str>;
using vii = vector<ii>;
using vpl = vector<pl>;
using vpd = vector<pd>;

#define tcT template<class T
#define tcTU tcT, class U

tcT> using V = vector<T>;
tcT, size_t SZ> using AR = array<T,SZ>;
tcT> using PR = pair<T,T>;

// pairs
#define mp make_pair

#define s second



#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

#define len(x) int((x).size())
#define bg(x) begin(x)
#define all(x) bg(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define sor(x) sort(all(x))
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pb push_back
#define eb emplace_back
#define pf push_front

const int MOD = 1e9+7; // 998244353;
const int MX = 1e5+5;
const ll INF = 1e18; // not too close to LLONG_MAX
const ld PI = acos((ld)-1);
const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1}; // for every grid problem!!

/*




#include <stdio.h>
#include <stdlib.h>


#define MAX_N 5000
#define MAX_CALLS 70000

#define fail(s, x...) do { \
		fprintf(stderr, s "\n", ## x); \
		exit(1); \
	} while(0)


#define N koala
#define realS kangaroo
#define realD possum
#define inv platypus
#define num_calls echidna

static int N;
static int realS[MAX_N];
static int realD[MAX_N];
static int inv[MAX_N];
static int num_calls;

void answer(int S[], int D[]) {
    int i;
    int correct = 1;
    for (i = 0; i < N; ++i)
        if (S[i] != realS[i] || D[i] != realD[i]) {
            correct = 0;
            break;
        }

    if (correct)
        printf("CORRECT\n");
    else
        printf("INCORRECT\n");

    for (i = 0; i < N; ++i) {
        if (i > 0)
            printf(" ");
        printf("%d", S[i]);
    }
    printf("\n");

    for (i = 0; i < N; ++i) {
        if (i > 0)
            printf(" ");
        printf("%d", D[i]);
    }
    printf("\n");

    exit(0);
}

int tryCombination(int S[]) {
    int i;

    if (num_calls >= MAX_CALLS) {
        printf("INCORRECT\nToo many calls to tryCombination().\n");
        exit(0);
    }
    ++num_calls;

    for (i = 0; i < N; ++i)
        if (S[inv[i]] != realS[inv[i]])
            return i;
    return -1;
}
*/
#include "cave.h"
void exploreCave(int N) {
    unordered_set<int> toIgnore;
    int vals[N];
    int doors[N];

    int cc;




    F0R(lev,N){
        vector<int> cands;
        F0R(i,N){
            if (toIgnore.find(i)==toIgnore.end()){
                cands.pb(i);
                vals[i]=0;
            }
        }

        if (tryCombination(vals) != lev) {
            cc=0;
        } else cc=1;
        F0R(i,N){
            if (toIgnore.find(i)==toIgnore.end()){

                vals[i]=cc;
            }
        }

        while (cands.size()>1){
            int half = cands.size()/2;
            vi reject_cands;
            F0R(i, half){
                int x = cands.back();
                cands.pop_back();
                reject_cands.pb(x);
            }
            trav(i, reject_cands) {
                vals[i] = 1-cc;
            }

            if (tryCombination(vals)!=lev){
                //success!
            }
            else {
                trav(i, reject_cands) {
                    vals[i]=cc;
                }
                trav(i, cands){
                    vals[i] = 1-cc;
                }
                cands = reject_cands;
            }


        }
        //cout << "cnd " << cands[0] << " cc " << vals[cands[0]] << endl;
        toIgnore.insert(cands[0]);
        doors[cands[0]] = lev;
        //cout << "------------------------------------------------"<<endl;
    }
    answer(vals,doors);

}
/*
int init() {
    int i, res;

    FILE *f = fopen("cave.in", "r");
    if (!f)
        fail("Failed to open input file.");

    res = fscanf(f, "%d", &N);

    for (i = 0; i < N; ++i) {
        res = fscanf(f, "%d", &realS[i]);
    }
    for (i = 0; i < N; ++i) {
        res = fscanf(f, "%d", &realD[i]);
        inv[realD[i]] = i;
    }

    num_calls = 0;
    return N;
}




int main() {
    int N;
    N = init();
    exploreCave(N);
    printf("INCORRECT\nYour solution did not call answer().\n");
    return 0;
}*/
# Verdict Execution time Memory Grader output
1 Correct 268 ms 588 KB Output is correct
2 Correct 261 ms 456 KB Output is correct
3 Correct 386 ms 504 KB Output is correct
4 Correct 271 ms 468 KB Output is correct
5 Correct 399 ms 612 KB Output is correct
6 Correct 387 ms 688 KB Output is correct
7 Correct 403 ms 600 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 304 KB Output is correct
12 Correct 380 ms 516 KB Output is correct
13 Correct 387 ms 584 KB Output is correct
14 Correct 386 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 402 ms 624 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 389 ms 500 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 393 ms 492 KB Output is correct
7 Correct 402 ms 628 KB Output is correct
8 Correct 624 ms 600 KB Output is correct
9 Correct 645 ms 688 KB Output is correct
10 Correct 631 ms 684 KB Output is correct
11 Correct 402 ms 592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 300 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 300 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 304 KB Output is correct
19 Correct 1 ms 304 KB Output is correct
20 Correct 66 ms 520 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 79 ms 312 KB Output is correct
24 Correct 78 ms 388 KB Output is correct
25 Correct 79 ms 340 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 62 ms 416 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 63 ms 416 KB Output is correct
31 Correct 64 ms 412 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 77 ms 400 KB Output is correct
36 Correct 78 ms 400 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 268 ms 588 KB Output is correct
2 Correct 261 ms 456 KB Output is correct
3 Correct 386 ms 504 KB Output is correct
4 Correct 271 ms 468 KB Output is correct
5 Correct 399 ms 612 KB Output is correct
6 Correct 387 ms 688 KB Output is correct
7 Correct 403 ms 600 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 304 KB Output is correct
12 Correct 380 ms 516 KB Output is correct
13 Correct 387 ms 584 KB Output is correct
14 Correct 386 ms 588 KB Output is correct
15 Correct 402 ms 624 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 389 ms 500 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 393 ms 492 KB Output is correct
21 Correct 402 ms 628 KB Output is correct
22 Correct 624 ms 600 KB Output is correct
23 Correct 645 ms 688 KB Output is correct
24 Correct 631 ms 684 KB Output is correct
25 Correct 402 ms 592 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 300 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Correct 1 ms 340 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 1 ms 304 KB Output is correct
44 Correct 1 ms 304 KB Output is correct
45 Correct 66 ms 520 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 79 ms 312 KB Output is correct
49 Correct 78 ms 388 KB Output is correct
50 Correct 79 ms 340 KB Output is correct
51 Correct 1 ms 212 KB Output is correct
52 Correct 1 ms 212 KB Output is correct
53 Correct 62 ms 416 KB Output is correct
54 Correct 1 ms 340 KB Output is correct
55 Correct 63 ms 416 KB Output is correct
56 Correct 64 ms 412 KB Output is correct
57 Correct 1 ms 212 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 1 ms 212 KB Output is correct
60 Correct 77 ms 400 KB Output is correct
61 Correct 78 ms 400 KB Output is correct
62 Correct 1 ms 212 KB Output is correct
63 Correct 263 ms 456 KB Output is correct
64 Correct 264 ms 548 KB Output is correct
65 Correct 390 ms 640 KB Output is correct
66 Correct 278 ms 468 KB Output is correct
67 Correct 392 ms 508 KB Output is correct
68 Correct 392 ms 588 KB Output is correct
69 Correct 400 ms 512 KB Output is correct
70 Correct 1 ms 304 KB Output is correct
71 Correct 1 ms 304 KB Output is correct
72 Correct 380 ms 492 KB Output is correct
73 Correct 388 ms 600 KB Output is correct
74 Correct 380 ms 492 KB Output is correct
75 Correct 392 ms 500 KB Output is correct
76 Correct 1 ms 340 KB Output is correct
77 Correct 0 ms 300 KB Output is correct
78 Correct 390 ms 500 KB Output is correct
79 Correct 399 ms 616 KB Output is correct
80 Correct 625 ms 588 KB Output is correct
81 Correct 633 ms 608 KB Output is correct
82 Correct 631 ms 500 KB Output is correct
83 Correct 401 ms 500 KB Output is correct
84 Correct 1 ms 212 KB Output is correct
85 Correct 64 ms 420 KB Output is correct
86 Correct 390 ms 492 KB Output is correct
87 Correct 1 ms 212 KB Output is correct
88 Correct 1 ms 212 KB Output is correct
89 Correct 80 ms 520 KB Output is correct
90 Correct 78 ms 420 KB Output is correct
91 Correct 79 ms 400 KB Output is correct
92 Correct 625 ms 596 KB Output is correct
93 Correct 621 ms 588 KB Output is correct
94 Correct 623 ms 716 KB Output is correct
95 Correct 1 ms 212 KB Output is correct
96 Correct 1 ms 212 KB Output is correct
97 Correct 388 ms 632 KB Output is correct
98 Correct 62 ms 400 KB Output is correct
99 Correct 388 ms 504 KB Output is correct
100 Correct 1 ms 212 KB Output is correct
101 Correct 68 ms 504 KB Output is correct
102 Correct 64 ms 388 KB Output is correct
103 Correct 396 ms 488 KB Output is correct
104 Correct 1 ms 212 KB Output is correct
105 Correct 1 ms 212 KB Output is correct
106 Correct 1 ms 212 KB Output is correct
107 Correct 82 ms 504 KB Output is correct
108 Correct 80 ms 388 KB Output is correct
109 Correct 631 ms 652 KB Output is correct
110 Correct 622 ms 488 KB Output is correct
111 Correct 0 ms 212 KB Output is correct