Submission #995603

# Submission time Handle Problem Language Result Execution time Memory
995603 2024-06-09T12:39:54 Z assanali Jakarta Skyscrapers (APIO15_skyscraper) C++17
0 / 100
1 ms 2904 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 long long
#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 = 2e18;
ll n,m,b[N],p[N],cost[30010][2010], d[30010];
vector <ll> v[N];
vector <ll> road[2010];
// 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);
}
for(ll j = 0; j< m; j++) {
    cost[j][b[j]]=0;
    v[j].pb(b[j]);
    for(ll i = 1; b[j] + i * p[j] < n; i += 1) {
        cost[j][b[j] + i * p[j]] = i;
        v[j].pb(b[j] + i * p[j]);
    }
    for(ll i = 1; b[j] - i * p[j] >= 0; i += 1) {
        cost[j][b[j] - i * p[j]] = i;
        v[j].pb(b[j] - i * p[j]);
    }
    sort(all(v[j]));
}
priority_queue <pll> q;
q.push({0,0});
d[0] = 0;
while(!q.empty()) {
    ll ver = q.top().S;    ll ttt = -q.top().F; q.pop();
    if(ttt > d[ver]) {continue;}
    for(auto u : v[ver]) {
        for(auto j : road[u]) {
            if(d[j] > d[ver] + cost[ver][u]) {
                d[j] = d[ver] + cost[ver][u];
                q.push({-d[j], j});
            }
        }
    }
}
cout<<d[1];
return 0;
}
// equal, min, max, 1, random, build
/*

*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 0 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Incorrect 1 ms 2904 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Incorrect 1 ms 2648 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Incorrect 1 ms 2648 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 0 ms 2652 KB Output is correct
4 Incorrect 0 ms 2652 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Incorrect 1 ms 2652 KB Output isn't correct
5 Halted 0 ms 0 KB -