Submission #548190

# Submission time Handle Problem Language Result Execution time Memory
548190 2022-04-12T16:32:56 Z Sergio_2357 Cave (IOI13_cave) C++17
100 / 100
1772 ms 468 KB
#include "cave.h"
#include <bits/stdc++.h>

using namespace std;

typedef vector<int> vi;

int find_pos(int d, vi& pos, vi& corr)
{
    int n = corr.size();
    int t[n];
    for (int i = 0; i < n; i++)
        t[i] = 0;
    for (int i = 0; i < d; i++)
        t[pos[i]] = corr[i];
    return (tryCombination(t) == d) ? 1 : 0;
}

bool test_range(int b, int e, int d, vi& used, vi& pos, vi& corr)
{
    int n = corr.size();
    int t[n];
    for (int i = 0; i < n; i++)
        t[i] = 1 - corr[d];
    for (int i = 0; i < d; i++)
        t[pos[i]] = corr[i];
    int c = 0;
    for (int i = 0; i < n; i++) {
        //cout << i << ' ' << c << endl;
        if (used[i])
            continue;
        if (c >= b && c < e)
            t[i] = corr[d];
        c++;
    }
    return tryCombination(t) != d;
}

void exploreCave(int n)
{
    vi pos(n, -1);
    vi corr(n, -1);
    vi used(n, 0);
    for (int d = 0; d < n; d++) {
        corr[d] = find_pos(d, pos, corr);
        //cout << d << ' ' << corr[d] << endl;
        int l = 0;
        int h = n - d;
        while (l < h - 1) {
            int m = (h - l) / 2 + l;
            if (test_range(l, m, d, used, pos, corr))
                h = m;
            else
                l = m;
        }
        int c = 0;
        for (int i = 0; i < n; i++) {
            if (used[i])
                continue;
            if (c == l) {
                pos[d] = i;
                used[i] = 1;
            }
            c++;
        }
    }
    int S[n];
    int D[n];
    for (int i = 0; i < n; i++) {
        //cout << corr[i] << ' ' << pos[i] << endl;
        S[pos[i]] = corr[i];
    }
    for (int i = 0; i < n; i++)
        D[pos[i]] = i;
    answer(S, D);
}
# Verdict Execution time Memory Grader output
1 Correct 643 ms 440 KB Output is correct
2 Correct 598 ms 436 KB Output is correct
3 Correct 946 ms 464 KB Output is correct
4 Correct 651 ms 432 KB Output is correct
5 Correct 1012 ms 456 KB Output is correct
6 Correct 937 ms 456 KB Output is correct
7 Correct 950 ms 448 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 304 KB Output is correct
11 Correct 1 ms 312 KB Output is correct
12 Correct 982 ms 460 KB Output is correct
13 Correct 964 ms 460 KB Output is correct
14 Correct 940 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1014 ms 460 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1048 ms 448 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1035 ms 444 KB Output is correct
7 Correct 1047 ms 444 KB Output is correct
8 Correct 1655 ms 444 KB Output is correct
9 Correct 1655 ms 448 KB Output is correct
10 Correct 1688 ms 448 KB Output is correct
11 Correct 1080 ms 456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 220 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 224 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 1 ms 224 KB Output is correct
9 Correct 1 ms 224 KB Output is correct
10 Correct 1 ms 316 KB Output is correct
11 Correct 1 ms 224 KB Output is correct
12 Correct 1 ms 224 KB Output is correct
13 Correct 1 ms 224 KB Output is correct
14 Correct 1 ms 224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 220 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 224 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 1 ms 224 KB Output is correct
9 Correct 1 ms 224 KB Output is correct
10 Correct 1 ms 316 KB Output is correct
11 Correct 1 ms 224 KB Output is correct
12 Correct 1 ms 224 KB Output is correct
13 Correct 1 ms 224 KB Output is correct
14 Correct 1 ms 224 KB Output is correct
15 Correct 1 ms 224 KB Output is correct
16 Correct 1 ms 316 KB Output is correct
17 Correct 1 ms 316 KB Output is correct
18 Correct 1 ms 224 KB Output is correct
19 Correct 1 ms 320 KB Output is correct
20 Correct 145 ms 368 KB Output is correct
21 Correct 1 ms 224 KB Output is correct
22 Correct 1 ms 324 KB Output is correct
23 Correct 220 ms 368 KB Output is correct
24 Correct 218 ms 368 KB Output is correct
25 Correct 221 ms 368 KB Output is correct
26 Correct 1 ms 224 KB Output is correct
27 Correct 1 ms 224 KB Output is correct
28 Correct 153 ms 368 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 145 ms 368 KB Output is correct
31 Correct 146 ms 340 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 216 ms 364 KB Output is correct
36 Correct 213 ms 380 KB Output is correct
37 Correct 0 ms 224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 643 ms 440 KB Output is correct
2 Correct 598 ms 436 KB Output is correct
3 Correct 946 ms 464 KB Output is correct
4 Correct 651 ms 432 KB Output is correct
5 Correct 1012 ms 456 KB Output is correct
6 Correct 937 ms 456 KB Output is correct
7 Correct 950 ms 448 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 304 KB Output is correct
11 Correct 1 ms 312 KB Output is correct
12 Correct 982 ms 460 KB Output is correct
13 Correct 964 ms 460 KB Output is correct
14 Correct 940 ms 460 KB Output is correct
15 Correct 1014 ms 460 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1048 ms 448 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1035 ms 444 KB Output is correct
21 Correct 1047 ms 444 KB Output is correct
22 Correct 1655 ms 444 KB Output is correct
23 Correct 1655 ms 448 KB Output is correct
24 Correct 1688 ms 448 KB Output is correct
25 Correct 1080 ms 456 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 304 KB Output is correct
28 Correct 1 ms 304 KB Output is correct
29 Correct 1 ms 220 KB Output is correct
30 Correct 1 ms 308 KB Output is correct
31 Correct 1 ms 224 KB Output is correct
32 Correct 1 ms 316 KB Output is correct
33 Correct 1 ms 224 KB Output is correct
34 Correct 1 ms 224 KB Output is correct
35 Correct 1 ms 316 KB Output is correct
36 Correct 1 ms 224 KB Output is correct
37 Correct 1 ms 224 KB Output is correct
38 Correct 1 ms 224 KB Output is correct
39 Correct 1 ms 224 KB Output is correct
40 Correct 1 ms 224 KB Output is correct
41 Correct 1 ms 316 KB Output is correct
42 Correct 1 ms 316 KB Output is correct
43 Correct 1 ms 224 KB Output is correct
44 Correct 1 ms 320 KB Output is correct
45 Correct 145 ms 368 KB Output is correct
46 Correct 1 ms 224 KB Output is correct
47 Correct 1 ms 324 KB Output is correct
48 Correct 220 ms 368 KB Output is correct
49 Correct 218 ms 368 KB Output is correct
50 Correct 221 ms 368 KB Output is correct
51 Correct 1 ms 224 KB Output is correct
52 Correct 1 ms 224 KB Output is correct
53 Correct 153 ms 368 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 145 ms 368 KB Output is correct
56 Correct 146 ms 340 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 216 ms 364 KB Output is correct
61 Correct 213 ms 380 KB Output is correct
62 Correct 0 ms 224 KB Output is correct
63 Correct 617 ms 436 KB Output is correct
64 Correct 604 ms 352 KB Output is correct
65 Correct 937 ms 460 KB Output is correct
66 Correct 627 ms 448 KB Output is correct
67 Correct 958 ms 460 KB Output is correct
68 Correct 955 ms 444 KB Output is correct
69 Correct 978 ms 456 KB Output is correct
70 Correct 1 ms 216 KB Output is correct
71 Correct 0 ms 212 KB Output is correct
72 Correct 932 ms 448 KB Output is correct
73 Correct 976 ms 448 KB Output is correct
74 Correct 916 ms 456 KB Output is correct
75 Correct 1044 ms 456 KB Output is correct
76 Correct 1 ms 220 KB Output is correct
77 Correct 1 ms 220 KB Output is correct
78 Correct 1072 ms 444 KB Output is correct
79 Correct 1095 ms 468 KB Output is correct
80 Correct 1656 ms 448 KB Output is correct
81 Correct 1629 ms 448 KB Output is correct
82 Correct 1630 ms 448 KB Output is correct
83 Correct 1087 ms 444 KB Output is correct
84 Correct 1 ms 212 KB Output is correct
85 Correct 148 ms 340 KB Output is correct
86 Correct 1018 ms 444 KB Output is correct
87 Correct 1 ms 212 KB Output is correct
88 Correct 1 ms 212 KB Output is correct
89 Correct 233 ms 364 KB Output is correct
90 Correct 215 ms 360 KB Output is correct
91 Correct 214 ms 360 KB Output is correct
92 Correct 1647 ms 456 KB Output is correct
93 Correct 1665 ms 448 KB Output is correct
94 Correct 1632 ms 448 KB Output is correct
95 Correct 1 ms 212 KB Output is correct
96 Correct 1 ms 212 KB Output is correct
97 Correct 1104 ms 448 KB Output is correct
98 Correct 181 ms 356 KB Output is correct
99 Correct 1046 ms 444 KB Output is correct
100 Correct 1 ms 212 KB Output is correct
101 Correct 145 ms 436 KB Output is correct
102 Correct 152 ms 372 KB Output is correct
103 Correct 1105 ms 448 KB Output is correct
104 Correct 1 ms 212 KB Output is correct
105 Correct 1 ms 300 KB Output is correct
106 Correct 1 ms 212 KB Output is correct
107 Correct 209 ms 340 KB Output is correct
108 Correct 215 ms 352 KB Output is correct
109 Correct 1772 ms 448 KB Output is correct
110 Correct 1717 ms 444 KB Output is correct
111 Correct 1 ms 212 KB Output is correct