답안 #896478

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
896478 2024-01-01T14:19:42 Z sysia 동굴 (IOI13_cave) C++17
100 / 100
466 ms 816 KB
//Sylwia Sapkowska
#pragma GCC optimize("O3", "unroll-loops")
#include <bits/stdc++.h>
#include "cave.h"
using namespace std;

void __print(int x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << "'" << x << "'";}
void __print(const char *x) {cerr << '"' << x << '"';}
void __print(const string &x) {cerr << '"' << x << '"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ", "; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? ", " : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


void exploreCave(int n) {
    vector<bool>fixed(n);
    int s[n], t[n], where[n];
    for (int i = 0; i<n; i++) s[i] = 0;
    
    for (int i = 1; i<=n; i++){
        int l = 0, r = n-1;
        int ans = 0;
        int curr = tryCombination(s);
        debug(i, curr);
        if (curr == -1) curr = n;
        while (r >= l){
            int mid = (l+r)/2;
            debug(mid);
            for (int j = 0; j<n; j++){
                t[j] = s[j];
                if (!fixed[j] && j <= mid){
                    t[j] = 1;
                }
            }
            int get = tryCombination(t);
            if (get == -1) get = n;
            if ((curr < i && get >= i) || (curr >= i && get < i)){
                ans = mid;
                r = mid-1;
            } else {
                l = mid+1;
            }
        }
        debug(i, ans);
        fixed[ans] = 1;
        where[ans] = i-1;
        s[ans] = (curr >= i ? 0 : 1);
    }
    answer(s, where);   
}
# 결과 실행 시간 메모리 Grader output
1 Correct 202 ms 508 KB Output is correct
2 Correct 225 ms 544 KB Output is correct
3 Correct 316 ms 348 KB Output is correct
4 Correct 208 ms 772 KB Output is correct
5 Correct 382 ms 560 KB Output is correct
6 Correct 308 ms 344 KB Output is correct
7 Correct 397 ms 564 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 299 ms 560 KB Output is correct
13 Correct 302 ms 344 KB Output is correct
14 Correct 304 ms 556 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 357 ms 520 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 320 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 356 ms 560 KB Output is correct
7 Correct 321 ms 556 KB Output is correct
8 Correct 422 ms 344 KB Output is correct
9 Correct 436 ms 348 KB Output is correct
10 Correct 420 ms 544 KB Output is correct
11 Correct 320 ms 560 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 44 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 58 ms 476 KB Output is correct
24 Correct 57 ms 348 KB Output is correct
25 Correct 57 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 52 ms 596 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 53 ms 344 KB Output is correct
31 Correct 48 ms 476 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 61 ms 348 KB Output is correct
36 Correct 63 ms 480 KB Output is correct
37 Correct 0 ms 360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 202 ms 508 KB Output is correct
2 Correct 225 ms 544 KB Output is correct
3 Correct 316 ms 348 KB Output is correct
4 Correct 208 ms 772 KB Output is correct
5 Correct 382 ms 560 KB Output is correct
6 Correct 308 ms 344 KB Output is correct
7 Correct 397 ms 564 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 299 ms 560 KB Output is correct
13 Correct 302 ms 344 KB Output is correct
14 Correct 304 ms 556 KB Output is correct
15 Correct 357 ms 520 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 320 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 356 ms 560 KB Output is correct
21 Correct 321 ms 556 KB Output is correct
22 Correct 422 ms 344 KB Output is correct
23 Correct 436 ms 348 KB Output is correct
24 Correct 420 ms 544 KB Output is correct
25 Correct 320 ms 560 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 1 ms 344 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 1 ms 344 KB Output is correct
44 Correct 1 ms 344 KB Output is correct
45 Correct 44 ms 348 KB Output is correct
46 Correct 0 ms 344 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 58 ms 476 KB Output is correct
49 Correct 57 ms 348 KB Output is correct
50 Correct 57 ms 348 KB Output is correct
51 Correct 0 ms 348 KB Output is correct
52 Correct 0 ms 348 KB Output is correct
53 Correct 52 ms 596 KB Output is correct
54 Correct 1 ms 348 KB Output is correct
55 Correct 53 ms 344 KB Output is correct
56 Correct 48 ms 476 KB Output is correct
57 Correct 0 ms 344 KB Output is correct
58 Correct 1 ms 348 KB Output is correct
59 Correct 0 ms 348 KB Output is correct
60 Correct 61 ms 348 KB Output is correct
61 Correct 63 ms 480 KB Output is correct
62 Correct 0 ms 360 KB Output is correct
63 Correct 206 ms 348 KB Output is correct
64 Correct 200 ms 344 KB Output is correct
65 Correct 348 ms 556 KB Output is correct
66 Correct 221 ms 540 KB Output is correct
67 Correct 362 ms 556 KB Output is correct
68 Correct 322 ms 560 KB Output is correct
69 Correct 366 ms 560 KB Output is correct
70 Correct 0 ms 348 KB Output is correct
71 Correct 0 ms 348 KB Output is correct
72 Correct 341 ms 452 KB Output is correct
73 Correct 331 ms 560 KB Output is correct
74 Correct 306 ms 348 KB Output is correct
75 Correct 341 ms 556 KB Output is correct
76 Correct 0 ms 348 KB Output is correct
77 Correct 0 ms 348 KB Output is correct
78 Correct 359 ms 556 KB Output is correct
79 Correct 329 ms 592 KB Output is correct
80 Correct 421 ms 348 KB Output is correct
81 Correct 429 ms 556 KB Output is correct
82 Correct 423 ms 348 KB Output is correct
83 Correct 323 ms 592 KB Output is correct
84 Correct 0 ms 348 KB Output is correct
85 Correct 43 ms 348 KB Output is correct
86 Correct 308 ms 816 KB Output is correct
87 Correct 1 ms 344 KB Output is correct
88 Correct 0 ms 344 KB Output is correct
89 Correct 59 ms 476 KB Output is correct
90 Correct 64 ms 348 KB Output is correct
91 Correct 58 ms 344 KB Output is correct
92 Correct 466 ms 552 KB Output is correct
93 Correct 416 ms 348 KB Output is correct
94 Correct 425 ms 500 KB Output is correct
95 Correct 1 ms 344 KB Output is correct
96 Correct 1 ms 348 KB Output is correct
97 Correct 331 ms 760 KB Output is correct
98 Correct 46 ms 344 KB Output is correct
99 Correct 355 ms 560 KB Output is correct
100 Correct 0 ms 348 KB Output is correct
101 Correct 49 ms 476 KB Output is correct
102 Correct 52 ms 480 KB Output is correct
103 Correct 300 ms 560 KB Output is correct
104 Correct 1 ms 500 KB Output is correct
105 Correct 0 ms 348 KB Output is correct
106 Correct 0 ms 348 KB Output is correct
107 Correct 78 ms 348 KB Output is correct
108 Correct 64 ms 596 KB Output is correct
109 Correct 456 ms 560 KB Output is correct
110 Correct 434 ms 556 KB Output is correct
111 Correct 0 ms 348 KB Output is correct