Submission #491034

# Submission time Handle Problem Language Result Execution time Memory
491034 2021-11-30T05:03:55 Z sberens Mecho (IOI09_mecho) C++17
0 / 100
13 ms 1364 KB
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
template<typename K> using hset = gp_hash_table<K, null_type>;
template<typename K, typename V> using hmap = gp_hash_table<K, V>;


using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define smax(x, y) (x = max(x, y))
#define smin(x, y) (x = min(x, y))

#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)


using ll = long long;
using ld = long double;

template<typename T>
using vv = vector<vector<T>>;

using vi = vector<int>;
using ii = array<int, 2>;
using vii = vector<ii>;
using vvi = vv<int>;

using vll = vector<ll>;
using l2 = array<ll, 2>;
using vl2 = vector<l2>;
using vvll = vv<ll>;

template<typename T>
using minq = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using maxq = priority_queue<T>;

const ll M = 1000000007;
const ll infll = M * M;

template<typename IN>
IN discrete_binary_search(function<bool(IN)> predicate, IN low = 0, IN high = numeric_limits<IN>::max()) {
    while (low < high) {
        IN middle = low + (high - low) / 2; // todo std::midpoint in cpp 2020
        if (predicate(middle))
            high = middle;
        else low = middle + 1;
    }
    return low;
}

vii dirs{{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

vii adjc(int x, int y) {
    vii res;
    for (auto [dx, dy] : dirs)
        res.pb({x + dx, y + dy});
    return res;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, s;
    cin >> n >> s;
    vv<char> g(n, vector<char>(n));
    int mr, mc, dr, dc;
    vii hives;
    F0R(i, n) {
        F0R(j, n) {
            char x;
            cin >> x;
            g[i][j] = x;
            if (x == 'M') {
                mr = i;
                mc = j;
            } else if (x == 'H') {
                hives.pb({i, j});
            } else if (x == 'D') {
                dr = i;
                dc = j;
            }
        }
    }
//    cout << discrete_binary_search<int>([&](int t) -> bool {
//        queue<ii> bees, bear;
//        vvi seenbees(n, vi(n)), seenbear(n, vi(n));
//        for (auto [r, c] : hives) {
//            bees.push({r, c});
//            seenbees[r][c] = 1;
//        }
//        bear.push({mr, mc});
//        seenbear[mr][mc] = 1;
//
//        auto upd_bees = [&]() -> void {
//            queue<ii> nextbees;
//            while (!bees.empty()) {
//                assert(bees.size() < n * n);
//                auto [r, c] = bees.front(); bees.pop();
//                for (auto [nr, nc] : adjc(r, c)) {
//                    if (0 <= nr && nr < n && 0 <= nc && nc < n && seenbees[nr][nc] == 0 && (g[nr][nc] == 'G' || g[nr][nc] == 'M')) {
//                        nextbees.push({nr, nc});
//                        seenbees[nr][nc] = 1;
//                    }
//                }
//            }
//            swap(bees, nextbees);
////            bees = nextbees;
//        };
//        F0R(_, t) upd_bees();
//        while (!bees.empty()) {
//            F0R(_, s) {
//                queue<ii> nextbear;
//                while (!bear.empty()) {
//                    assert(bear.size() < n * n);
//                    auto [r, c] = bear.front(); bear.pop();
//                    if (seenbees[r][c] == 1) continue;
//                    if (r == dr && c == dc) return false;
//                    for (auto [nr, nc] : adjc(r, c)) {
//                        if (0 <= nr && nr < n && 0 <= nc && nc < n && seenbear[nr][nc] == 0 && (g[nr][nc] == 'G' || g[nr][nc] == 'D') && seenbees[nr][nc] == 0) {
//                            nextbear.push({nr, nc});
//                            seenbear[nr][nc] = 1;
//                        }
//                    }
//                }
//                swap(bear, nextbear);
//                if (bear.empty()) return true;
////                bear = nextbear;
//            }
//            upd_bees();
//        }
//        return true;
//    }, 0, n * n) - 1 << '\n';

}

Compilation message

mecho.cpp: In function 'int main()':
mecho.cpp:74:9: warning: variable 'mr' set but not used [-Wunused-but-set-variable]
   74 |     int mr, mc, dr, dc;
      |         ^~
mecho.cpp:74:13: warning: variable 'mc' set but not used [-Wunused-but-set-variable]
   74 |     int mr, mc, dr, dc;
      |             ^~
mecho.cpp:74:17: warning: variable 'dr' set but not used [-Wunused-but-set-variable]
   74 |     int mr, mc, dr, dc;
      |                 ^~
mecho.cpp:74:21: warning: variable 'dc' set but not used [-Wunused-but-set-variable]
   74 |     int mr, mc, dr, dc;
      |                     ^~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Incorrect 0 ms 204 KB Output isn't correct
4 Incorrect 0 ms 204 KB Output isn't correct
5 Incorrect 0 ms 204 KB Output isn't correct
6 Incorrect 1 ms 204 KB Output isn't correct
7 Incorrect 10 ms 1228 KB Output isn't correct
8 Incorrect 0 ms 204 KB Output isn't correct
9 Incorrect 0 ms 204 KB Output isn't correct
10 Incorrect 0 ms 204 KB Output isn't correct
11 Incorrect 0 ms 204 KB Output isn't correct
12 Incorrect 1 ms 204 KB Output isn't correct
13 Incorrect 0 ms 204 KB Output isn't correct
14 Incorrect 0 ms 204 KB Output isn't correct
15 Incorrect 1 ms 204 KB Output isn't correct
16 Incorrect 0 ms 204 KB Output isn't correct
17 Incorrect 0 ms 204 KB Output isn't correct
18 Incorrect 0 ms 204 KB Output isn't correct
19 Incorrect 0 ms 204 KB Output isn't correct
20 Incorrect 1 ms 204 KB Output isn't correct
21 Incorrect 1 ms 204 KB Output isn't correct
22 Incorrect 0 ms 204 KB Output isn't correct
23 Incorrect 1 ms 312 KB Output isn't correct
24 Incorrect 1 ms 204 KB Output isn't correct
25 Incorrect 0 ms 204 KB Output isn't correct
26 Incorrect 0 ms 204 KB Output isn't correct
27 Incorrect 0 ms 204 KB Output isn't correct
28 Incorrect 0 ms 204 KB Output isn't correct
29 Incorrect 0 ms 204 KB Output isn't correct
30 Incorrect 1 ms 204 KB Output isn't correct
31 Incorrect 0 ms 204 KB Output isn't correct
32 Incorrect 0 ms 316 KB Output isn't correct
33 Incorrect 2 ms 460 KB Output isn't correct
34 Incorrect 2 ms 460 KB Output isn't correct
35 Incorrect 2 ms 460 KB Output isn't correct
36 Incorrect 3 ms 588 KB Output isn't correct
37 Incorrect 3 ms 588 KB Output isn't correct
38 Incorrect 3 ms 588 KB Output isn't correct
39 Incorrect 4 ms 716 KB Output isn't correct
40 Incorrect 4 ms 716 KB Output isn't correct
41 Incorrect 3 ms 716 KB Output isn't correct
42 Incorrect 4 ms 716 KB Output isn't correct
43 Incorrect 4 ms 716 KB Output isn't correct
44 Incorrect 5 ms 716 KB Output isn't correct
45 Incorrect 6 ms 844 KB Output isn't correct
46 Incorrect 6 ms 844 KB Output isn't correct
47 Incorrect 5 ms 844 KB Output isn't correct
48 Incorrect 6 ms 972 KB Output isn't correct
49 Incorrect 5 ms 972 KB Output isn't correct
50 Incorrect 7 ms 972 KB Output isn't correct
51 Incorrect 6 ms 1100 KB Output isn't correct
52 Incorrect 7 ms 1100 KB Output isn't correct
53 Incorrect 7 ms 1100 KB Output isn't correct
54 Incorrect 9 ms 1100 KB Output isn't correct
55 Incorrect 9 ms 1092 KB Output isn't correct
56 Incorrect 8 ms 1100 KB Output isn't correct
57 Incorrect 9 ms 1228 KB Output isn't correct
58 Incorrect 8 ms 1228 KB Output isn't correct
59 Incorrect 8 ms 1228 KB Output isn't correct
60 Incorrect 9 ms 1228 KB Output isn't correct
61 Incorrect 10 ms 1216 KB Output isn't correct
62 Incorrect 10 ms 1228 KB Output isn't correct
63 Incorrect 10 ms 1228 KB Output isn't correct
64 Incorrect 10 ms 1228 KB Output isn't correct
65 Incorrect 10 ms 1228 KB Output isn't correct
66 Incorrect 10 ms 1228 KB Output isn't correct
67 Incorrect 10 ms 1228 KB Output isn't correct
68 Incorrect 10 ms 1228 KB Output isn't correct
69 Incorrect 10 ms 1228 KB Output isn't correct
70 Incorrect 10 ms 1328 KB Output isn't correct
71 Incorrect 10 ms 1336 KB Output isn't correct
72 Incorrect 10 ms 1228 KB Output isn't correct
73 Incorrect 10 ms 1364 KB Output isn't correct
74 Incorrect 11 ms 1340 KB Output isn't correct
75 Incorrect 11 ms 1356 KB Output isn't correct
76 Incorrect 10 ms 1356 KB Output isn't correct
77 Incorrect 10 ms 1356 KB Output isn't correct
78 Incorrect 10 ms 1356 KB Output isn't correct
79 Incorrect 11 ms 1268 KB Output isn't correct
80 Incorrect 11 ms 1348 KB Output isn't correct
81 Incorrect 10 ms 1224 KB Output isn't correct
82 Incorrect 13 ms 1356 KB Output isn't correct
83 Incorrect 11 ms 1356 KB Output isn't correct
84 Incorrect 11 ms 1344 KB Output isn't correct
85 Incorrect 11 ms 1356 KB Output isn't correct
86 Incorrect 9 ms 1340 KB Output isn't correct
87 Incorrect 9 ms 1328 KB Output isn't correct
88 Incorrect 10 ms 1228 KB Output isn't correct
89 Incorrect 11 ms 1340 KB Output isn't correct
90 Incorrect 11 ms 1340 KB Output isn't correct
91 Incorrect 10 ms 1324 KB Output isn't correct
92 Incorrect 12 ms 1332 KB Output isn't correct