Submission #738478

# Submission time Handle Problem Language Result Execution time Memory
738478 2023-05-08T20:18:12 Z Vanilla Jakarta Skyscrapers (APIO15_skyscraper) C++17
100 / 100
240 ms 112232 KB
#include <bits/stdc++.h>
#include <fstream>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
struct custom_hash {static uint64_t splitmix64(uint64_t x) {x += 0x9e3779b97f4a7c15;x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;x = (x ^ (x >> 27)) * 0x94d049bb133111eb;return x ^ (x >> 31);}size_t operator()(uint64_t x) const {static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();return splitmix64(x + FIXED_RANDOM);}};
// string __fname = ""; ifstream in (__fname + ".in"); ofstream out (__fname + ".out"); 
// #define cin in 
// #define cout out
#define int64 long long
#define uint64 unsigned long long
#define x first
#define y second
#define pb push_back
#define pii pair <int, int> 
#define pii64 pair <int64, int64>
#define db(x) cout << "> " << #x << ": " << (x) << "\n"
#define qr queries()
#define yn(x) if (x) {ctn("Yes");}else {ctn("No");}
void solve(int);
void queries(){int n;cin >> n;for (int i = 1; i <= n; i++) solve(i);}
template<class T>T ceildiv(T a, T b) {return a / b + !!(a % b);}
template<class T>T gcd (T a, T b){return (b ? gcd(b, a % b): a);}
template<class T>T lcm (T a, T b){return a * b / gcd(a, b);}
// // // // // // // // // // // // // // // // // // // // // // 
/*                  TEMPLATE - VANILLA                         */
// // // // // // // // // // // // // // // // // // // // // //
const int ddx[] = {-1, -1, 0, 1, 1, 1, 0, -1};
const int ddy[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
const double pi = 3.14159265359;
const double eps = 1e-6;
const int64 hash_inv = 940594066;
const int64 hash_p = 101;
const int64 mod = 1e9 + 7;
const int maxn = 3e4 + 1;
bitset <maxn> vis [maxn];
vector <int> ad [maxn];

void solve(int id){
    
    return;
}


int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed; cout << setprecision(10); 
    int n,m, start= 0, end= 0;
    cin >> n >> m;
    for (int i = 0; i < m; i++){
        int x,y;
        cin >> x >> y;
        if (x + y < n) ad[x].push_back(y);
        if (x - y >= 0) ad[x].push_back(-y);
        if (i == 0) start = x;
        if (i == 1) end = x;
    }
    queue <array <int, 3> > q;
    q.push({start, 0, 0});
    while (!q.empty()) {
        auto [pos, jump, dist] = q.front();
        // cerr << pos << " " << jump << " " << dist << "\n";
        q.pop();
        if (pos == end) {
            cout << dist;
            return 0;
        }
        if (jump && pos + jump >= 0 && pos + jump < n && !vis[pos][pos + jump]) {
            vis[pos][pos + jump] = 1;
            q.push({pos + jump, jump, dist + 1});
        }
        for (int njump: ad[pos]) {
            if (vis[pos][pos + njump]) continue;
            vis[pos][pos + njump] = 1;
            q.push({pos + njump, njump, dist + 1});
        }
    }
    cout << "-1";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 1 ms 980 KB Output is correct
5 Correct 1 ms 980 KB Output is correct
6 Correct 1 ms 980 KB Output is correct
7 Correct 1 ms 980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 1 ms 980 KB Output is correct
5 Correct 1 ms 980 KB Output is correct
6 Correct 1 ms 980 KB Output is correct
7 Correct 1 ms 980 KB Output is correct
8 Correct 1 ms 980 KB Output is correct
9 Correct 1 ms 1032 KB Output is correct
10 Correct 1 ms 1032 KB Output is correct
11 Correct 1 ms 1044 KB Output is correct
12 Correct 1 ms 1364 KB Output is correct
13 Correct 1 ms 1364 KB Output is correct
14 Correct 1 ms 1364 KB Output is correct
15 Correct 1 ms 1236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 1 ms 980 KB Output is correct
5 Correct 1 ms 1032 KB Output is correct
6 Correct 1 ms 1036 KB Output is correct
7 Correct 1 ms 980 KB Output is correct
8 Correct 1 ms 980 KB Output is correct
9 Correct 1 ms 1108 KB Output is correct
10 Correct 1 ms 1108 KB Output is correct
11 Correct 1 ms 980 KB Output is correct
12 Correct 1 ms 1364 KB Output is correct
13 Correct 1 ms 1364 KB Output is correct
14 Correct 1 ms 1364 KB Output is correct
15 Correct 1 ms 1236 KB Output is correct
16 Correct 1 ms 1048 KB Output is correct
17 Correct 2 ms 3284 KB Output is correct
18 Correct 1 ms 1044 KB Output is correct
19 Correct 1 ms 980 KB Output is correct
20 Correct 5 ms 8344 KB Output is correct
21 Correct 1 ms 980 KB Output is correct
22 Correct 1 ms 980 KB Output is correct
23 Correct 4 ms 6100 KB Output is correct
24 Correct 4 ms 7064 KB Output is correct
25 Correct 2 ms 2004 KB Output is correct
26 Correct 4 ms 7252 KB Output is correct
27 Correct 5 ms 7648 KB Output is correct
28 Correct 6 ms 8344 KB Output is correct
29 Correct 6 ms 8276 KB Output is correct
30 Correct 5 ms 8276 KB Output is correct
31 Correct 5 ms 8204 KB Output is correct
32 Correct 5 ms 8332 KB Output is correct
33 Correct 7 ms 8404 KB Output is correct
34 Correct 6 ms 8148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 984 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 1 ms 980 KB Output is correct
5 Correct 1 ms 1040 KB Output is correct
6 Correct 1 ms 980 KB Output is correct
7 Correct 1 ms 980 KB Output is correct
8 Correct 1 ms 980 KB Output is correct
9 Correct 1 ms 1108 KB Output is correct
10 Correct 1 ms 1040 KB Output is correct
11 Correct 1 ms 980 KB Output is correct
12 Correct 1 ms 1304 KB Output is correct
13 Correct 1 ms 1364 KB Output is correct
14 Correct 2 ms 1364 KB Output is correct
15 Correct 2 ms 1308 KB Output is correct
16 Correct 1 ms 1044 KB Output is correct
17 Correct 2 ms 3352 KB Output is correct
18 Correct 1 ms 1044 KB Output is correct
19 Correct 1 ms 980 KB Output is correct
20 Correct 6 ms 8404 KB Output is correct
21 Correct 1 ms 980 KB Output is correct
22 Correct 1 ms 980 KB Output is correct
23 Correct 4 ms 6104 KB Output is correct
24 Correct 5 ms 7064 KB Output is correct
25 Correct 2 ms 1948 KB Output is correct
26 Correct 5 ms 7252 KB Output is correct
27 Correct 5 ms 7704 KB Output is correct
28 Correct 6 ms 8412 KB Output is correct
29 Correct 5 ms 8276 KB Output is correct
30 Correct 5 ms 8284 KB Output is correct
31 Correct 6 ms 8148 KB Output is correct
32 Correct 5 ms 8284 KB Output is correct
33 Correct 7 ms 8344 KB Output is correct
34 Correct 6 ms 8092 KB Output is correct
35 Correct 9 ms 6744 KB Output is correct
36 Correct 2 ms 2264 KB Output is correct
37 Correct 7 ms 5716 KB Output is correct
38 Correct 10 ms 7704 KB Output is correct
39 Correct 6 ms 1496 KB Output is correct
40 Correct 7 ms 1668 KB Output is correct
41 Correct 7 ms 2840 KB Output is correct
42 Correct 8 ms 7896 KB Output is correct
43 Correct 8 ms 8156 KB Output is correct
44 Correct 9 ms 8956 KB Output is correct
45 Correct 17 ms 9048 KB Output is correct
46 Correct 13 ms 8268 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 988 KB Output is correct
3 Correct 1 ms 988 KB Output is correct
4 Correct 1 ms 988 KB Output is correct
5 Correct 1 ms 1040 KB Output is correct
6 Correct 1 ms 984 KB Output is correct
7 Correct 1 ms 984 KB Output is correct
8 Correct 1 ms 984 KB Output is correct
9 Correct 1 ms 1108 KB Output is correct
10 Correct 1 ms 1108 KB Output is correct
11 Correct 1 ms 1044 KB Output is correct
12 Correct 1 ms 1364 KB Output is correct
13 Correct 1 ms 1364 KB Output is correct
14 Correct 1 ms 1368 KB Output is correct
15 Correct 1 ms 1240 KB Output is correct
16 Correct 1 ms 988 KB Output is correct
17 Correct 2 ms 3356 KB Output is correct
18 Correct 1 ms 980 KB Output is correct
19 Correct 1 ms 980 KB Output is correct
20 Correct 5 ms 8404 KB Output is correct
21 Correct 1 ms 980 KB Output is correct
22 Correct 1 ms 980 KB Output is correct
23 Correct 4 ms 6032 KB Output is correct
24 Correct 5 ms 7124 KB Output is correct
25 Correct 2 ms 1944 KB Output is correct
26 Correct 5 ms 7252 KB Output is correct
27 Correct 5 ms 7680 KB Output is correct
28 Correct 6 ms 8344 KB Output is correct
29 Correct 6 ms 8304 KB Output is correct
30 Correct 5 ms 8276 KB Output is correct
31 Correct 5 ms 8148 KB Output is correct
32 Correct 5 ms 8276 KB Output is correct
33 Correct 8 ms 8404 KB Output is correct
34 Correct 6 ms 8084 KB Output is correct
35 Correct 8 ms 6740 KB Output is correct
36 Correct 2 ms 2260 KB Output is correct
37 Correct 8 ms 5788 KB Output is correct
38 Correct 10 ms 7704 KB Output is correct
39 Correct 6 ms 1536 KB Output is correct
40 Correct 8 ms 1688 KB Output is correct
41 Correct 7 ms 2900 KB Output is correct
42 Correct 8 ms 7892 KB Output is correct
43 Correct 8 ms 8148 KB Output is correct
44 Correct 9 ms 8956 KB Output is correct
45 Correct 18 ms 9088 KB Output is correct
46 Correct 13 ms 8352 KB Output is correct
47 Correct 11 ms 10324 KB Output is correct
48 Correct 6 ms 1624 KB Output is correct
49 Correct 5 ms 1492 KB Output is correct
50 Correct 5 ms 1364 KB Output is correct
51 Correct 49 ms 70348 KB Output is correct
52 Correct 56 ms 76116 KB Output is correct
53 Correct 12 ms 13908 KB Output is correct
54 Correct 35 ms 61132 KB Output is correct
55 Correct 46 ms 77888 KB Output is correct
56 Correct 84 ms 112232 KB Output is correct
57 Correct 2 ms 2644 KB Output is correct
58 Correct 66 ms 111576 KB Output is correct
59 Correct 66 ms 103956 KB Output is correct
60 Correct 67 ms 104004 KB Output is correct
61 Correct 64 ms 98684 KB Output is correct
62 Correct 115 ms 111956 KB Output is correct
63 Correct 126 ms 111092 KB Output is correct
64 Correct 130 ms 110944 KB Output is correct
65 Correct 200 ms 111508 KB Output is correct
66 Correct 240 ms 111928 KB Output is correct
67 Correct 144 ms 111032 KB Output is correct