Submission #998821

# Submission time Handle Problem Language Result Execution time Memory
998821 2024-06-14T17:18:15 Z assanali Jakarta Skyscrapers (APIO15_skyscraper) C++17
57 / 100
1000 ms 5724 KB
/*

author: CRISTIANO RONALDO


#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
can do: find_by_order, order_of_key

__builtin_clz(x): the number of zeros at the beginning of the number
__builtin_ctz(x): the number of zeros at the end of the number
__builtin_popcount(x): the number of ones in the number
__builtin_parity(x): the parity (even or odd) of the number of ones

mt19937 rng(15);
mt19937 bruh(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rofl(chrono::steady_clock::now().time_since_epoch().count());
*/
#include <bits/stdc++.h>
#define ll int
#define all(a) a.begin(), a.end()
#define F first
#define S second
#define pb push_back
#define ull unsigned long long
#define ld long double
#define lv v+v
#define rv v+v+1
#define files freopen("aa.txt", "r", stdin), freopen("aa.txt", "w", stdout)
#define pll pair <long long, long long>
#define pii pair <int, int>
using namespace std;
long long mod = 1e9 + 7;
const ll N = 3e4 + 10;
const ll M = 2e3 + 10;
const ll P = 337ll;
const ld EPS = 1e-7;
const ll block = 325;
const ll inf = 2e9;
ll n,m,b[N],p[N], d[30010];
vector <ll> road[30010];
// v[j] - куда может прыгнуть собака j
// cost[j][u] - цена прыжка собаки j в точку u
// road[j] - Какие собаки живут в точке j
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cin>>n>>m;
for(ll i = 0; i<m; i++) {
    cin>>b[i]>>p[i];
    d[i] = inf;
    road[b[i]].pb(i);
}
set <pii> q;
q.insert({0,0});
d[0] = 0;
ll ver, ttt, j;
while(!q.empty()) {
    ver = (*q.begin()).S;    ttt = (*q.begin()).F; q.erase(q.begin());
    if(ttt > d[ver]) {continue;}
    j = ver;
    for(ll i = 1; b[j] + i * p[j] < n; i += 1) {
        if(!road[b[j] + i * p[j]].empty()) {
            for(auto jj : road[b[j] + i * p[j]]) {
                if(d[jj] > d[ver] + i) {
                    d[jj] = d[ver] + i;
                    q.insert({d[jj], jj});
                }
            }
        }
    }
    for(ll i = 0; b[j] - i * p[j] >= 0; i += 1) {
        if(!road[b[j] - i * p[j]].empty()) {
            for(auto jj : road[b[j] - i * p[j]]) {
                if(d[jj] > d[ver] + i) {
                    d[jj] = d[ver] + i;
                    q.insert({d[jj], jj});
                }
            }
        }
    }
}
cout<<(d[1] == inf ? -1 : d[1]);
return 0;
}
// equal, min, max, 1, random, build
/*

*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 0 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 0 ms 1116 KB Output is correct
3 Correct 0 ms 1116 KB Output is correct
4 Correct 0 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 0 ms 1116 KB Output is correct
8 Correct 1 ms 1116 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 2 ms 1116 KB Output is correct
12 Correct 4 ms 1116 KB Output is correct
13 Correct 3 ms 1112 KB Output is correct
14 Correct 1 ms 1372 KB Output is correct
15 Correct 2 ms 1372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 0 ms 1116 KB Output is correct
6 Correct 0 ms 1116 KB Output is correct
7 Correct 0 ms 1116 KB Output is correct
8 Correct 1 ms 1116 KB Output is correct
9 Correct 0 ms 1116 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 1 ms 1116 KB Output is correct
12 Correct 4 ms 1116 KB Output is correct
13 Correct 3 ms 1116 KB Output is correct
14 Correct 1 ms 1372 KB Output is correct
15 Correct 2 ms 1372 KB Output is correct
16 Correct 1 ms 1116 KB Output is correct
17 Correct 2 ms 1116 KB Output is correct
18 Correct 1 ms 1116 KB Output is correct
19 Correct 1 ms 1116 KB Output is correct
20 Correct 9 ms 1356 KB Output is correct
21 Correct 1 ms 1116 KB Output is correct
22 Correct 1 ms 1116 KB Output is correct
23 Correct 1 ms 1116 KB Output is correct
24 Correct 1 ms 1116 KB Output is correct
25 Correct 1 ms 1112 KB Output is correct
26 Correct 10 ms 1116 KB Output is correct
27 Correct 8 ms 1116 KB Output is correct
28 Correct 1 ms 1116 KB Output is correct
29 Correct 1 ms 1112 KB Output is correct
30 Correct 0 ms 1116 KB Output is correct
31 Correct 1 ms 1116 KB Output is correct
32 Correct 1 ms 1116 KB Output is correct
33 Correct 1 ms 1204 KB Output is correct
34 Correct 2 ms 1624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 0 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 0 ms 1116 KB Output is correct
7 Correct 1 ms 1112 KB Output is correct
8 Correct 1 ms 1112 KB Output is correct
9 Correct 0 ms 1116 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 2 ms 1116 KB Output is correct
12 Correct 4 ms 1116 KB Output is correct
13 Correct 3 ms 1116 KB Output is correct
14 Correct 2 ms 1372 KB Output is correct
15 Correct 1 ms 1372 KB Output is correct
16 Correct 1 ms 1116 KB Output is correct
17 Correct 2 ms 1116 KB Output is correct
18 Correct 1 ms 1116 KB Output is correct
19 Correct 1 ms 1112 KB Output is correct
20 Correct 13 ms 1356 KB Output is correct
21 Correct 1 ms 1116 KB Output is correct
22 Correct 1 ms 1116 KB Output is correct
23 Correct 1 ms 1116 KB Output is correct
24 Correct 2 ms 1116 KB Output is correct
25 Correct 1 ms 1116 KB Output is correct
26 Correct 8 ms 1116 KB Output is correct
27 Correct 8 ms 1116 KB Output is correct
28 Correct 1 ms 1116 KB Output is correct
29 Correct 1 ms 1116 KB Output is correct
30 Correct 0 ms 1116 KB Output is correct
31 Correct 1 ms 1116 KB Output is correct
32 Correct 1 ms 1116 KB Output is correct
33 Correct 2 ms 1372 KB Output is correct
34 Correct 2 ms 1372 KB Output is correct
35 Correct 21 ms 4260 KB Output is correct
36 Correct 3 ms 1372 KB Output is correct
37 Correct 20 ms 4044 KB Output is correct
38 Correct 29 ms 5720 KB Output is correct
39 Correct 28 ms 4836 KB Output is correct
40 Correct 29 ms 5724 KB Output is correct
41 Correct 27 ms 5468 KB Output is correct
42 Correct 588 ms 2908 KB Output is correct
43 Correct 573 ms 3016 KB Output is correct
44 Correct 652 ms 2908 KB Output is correct
45 Correct 25 ms 5464 KB Output is correct
46 Correct 25 ms 5464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1144 KB Output is correct
3 Correct 0 ms 1116 KB Output is correct
4 Correct 0 ms 1116 KB Output is correct
5 Correct 0 ms 1116 KB Output is correct
6 Correct 0 ms 1116 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
8 Correct 1 ms 1112 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 1 ms 1116 KB Output is correct
12 Correct 4 ms 1116 KB Output is correct
13 Correct 3 ms 1116 KB Output is correct
14 Correct 1 ms 1372 KB Output is correct
15 Correct 1 ms 1372 KB Output is correct
16 Correct 1 ms 1116 KB Output is correct
17 Correct 2 ms 1116 KB Output is correct
18 Correct 0 ms 1116 KB Output is correct
19 Correct 0 ms 1116 KB Output is correct
20 Correct 9 ms 1116 KB Output is correct
21 Correct 1 ms 1116 KB Output is correct
22 Correct 1 ms 1116 KB Output is correct
23 Correct 1 ms 1116 KB Output is correct
24 Correct 1 ms 1116 KB Output is correct
25 Correct 1 ms 1116 KB Output is correct
26 Correct 8 ms 1304 KB Output is correct
27 Correct 7 ms 1116 KB Output is correct
28 Correct 1 ms 1116 KB Output is correct
29 Correct 1 ms 1116 KB Output is correct
30 Correct 1 ms 1116 KB Output is correct
31 Correct 1 ms 1116 KB Output is correct
32 Correct 1 ms 1116 KB Output is correct
33 Correct 2 ms 1372 KB Output is correct
34 Correct 2 ms 1372 KB Output is correct
35 Correct 20 ms 4460 KB Output is correct
36 Correct 3 ms 1368 KB Output is correct
37 Correct 20 ms 3932 KB Output is correct
38 Correct 29 ms 5724 KB Output is correct
39 Correct 26 ms 4696 KB Output is correct
40 Correct 30 ms 5716 KB Output is correct
41 Correct 30 ms 5468 KB Output is correct
42 Correct 607 ms 2904 KB Output is correct
43 Correct 575 ms 2908 KB Output is correct
44 Correct 650 ms 2904 KB Output is correct
45 Correct 25 ms 5468 KB Output is correct
46 Correct 24 ms 5316 KB Output is correct
47 Correct 39 ms 5716 KB Output is correct
48 Correct 6 ms 1884 KB Output is correct
49 Correct 4 ms 1884 KB Output is correct
50 Correct 3 ms 1856 KB Output is correct
51 Correct 29 ms 5464 KB Output is correct
52 Correct 29 ms 5200 KB Output is correct
53 Correct 12 ms 4184 KB Output is correct
54 Correct 1 ms 1116 KB Output is correct
55 Correct 1 ms 1116 KB Output is correct
56 Execution timed out 1098 ms 3840 KB Time limit exceeded
57 Halted 0 ms 0 KB -