Submission #1110705

# Submission time Handle Problem Language Result Execution time Memory
1110705 2024-11-10T08:36:56 Z Edwardalex Jakarta Skyscrapers (APIO15_skyscraper) C++14
22 / 100
5 ms 2660 KB
#include <bits/stdc++.h>
#define fi first
#define si second
#define int long long
using namespace std;
const int N = 5e4 + 4;
int dist[N],n,m;
priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> q;
vector<int> g[N];
pair<int,int> a[N];
signed main()
{
    cin >> n >> m;
    for(int i = 1; i <= m; i++)
    {
        cin >> a[i].fi >> a[i].si;
        a[i].fi++;
        g[a[i].fi].push_back(a[i].si);
    }
    for(int i = 1; i <= n; i++) dist[i] = 1e18;
    q.push({0,a[1].fi});
    dist[a[1].first] = 0;
    while(!q.empty())
    {
        pair<int,int> node = q.top();q.pop();
        int u = node.si, d = node.fi;
        if(d >= 5000) {continue;}
        if(dist[u] < d) continue;
        for(int p : g[u])
        {   int t = d;
            for(int i = u  + p; i <= n; i += p)
            {   t++;
                if(dist[i] > t)
                {
                    dist[i] = t;
                    q.push({dist[i],i});
                }
            }
            t = d;
            for(int i = u - p; i > 0; i -= p)
            {
                t++;
                if(dist[i] > t)
                {
                    dist[i] = t;
                    q.push({dist[i],i});
                }
            }
        }
    }
    if(dist[a[2].first] == 1e18) cout << -1;
    else cout << dist[a[2].first];
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2552 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2556 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 2 ms 2384 KB Output is correct
12 Correct 2 ms 2384 KB Output is correct
13 Correct 2 ms 2384 KB Output is correct
14 Correct 2 ms 2384 KB Output is correct
15 Correct 1 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2552 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 2 ms 2384 KB Output is correct
12 Correct 2 ms 2384 KB Output is correct
13 Correct 1 ms 2384 KB Output is correct
14 Correct 2 ms 2560 KB Output is correct
15 Correct 2 ms 2384 KB Output is correct
16 Correct 1 ms 2384 KB Output is correct
17 Correct 2 ms 2600 KB Output is correct
18 Correct 2 ms 2556 KB Output is correct
19 Correct 2 ms 2384 KB Output is correct
20 Correct 4 ms 2640 KB Output is correct
21 Correct 2 ms 2384 KB Output is correct
22 Correct 1 ms 2384 KB Output is correct
23 Correct 2 ms 2384 KB Output is correct
24 Correct 2 ms 2548 KB Output is correct
25 Correct 2 ms 2640 KB Output is correct
26 Correct 4 ms 2384 KB Output is correct
27 Correct 4 ms 2384 KB Output is correct
28 Incorrect 2 ms 2556 KB Output isn't correct
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2556 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 2 ms 2384 KB Output is correct
12 Correct 2 ms 2384 KB Output is correct
13 Correct 2 ms 2384 KB Output is correct
14 Correct 2 ms 2384 KB Output is correct
15 Correct 2 ms 2384 KB Output is correct
16 Correct 1 ms 2552 KB Output is correct
17 Correct 2 ms 2384 KB Output is correct
18 Correct 1 ms 2384 KB Output is correct
19 Correct 1 ms 2384 KB Output is correct
20 Correct 4 ms 2652 KB Output is correct
21 Correct 1 ms 2384 KB Output is correct
22 Correct 1 ms 2384 KB Output is correct
23 Correct 2 ms 2384 KB Output is correct
24 Correct 3 ms 2384 KB Output is correct
25 Correct 2 ms 2640 KB Output is correct
26 Correct 3 ms 2384 KB Output is correct
27 Correct 3 ms 2556 KB Output is correct
28 Incorrect 2 ms 2384 KB Output isn't correct
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 2 ms 2384 KB Output is correct
12 Correct 2 ms 2384 KB Output is correct
13 Correct 1 ms 2384 KB Output is correct
14 Correct 2 ms 2384 KB Output is correct
15 Correct 1 ms 2384 KB Output is correct
16 Correct 1 ms 2384 KB Output is correct
17 Correct 2 ms 2384 KB Output is correct
18 Correct 1 ms 2384 KB Output is correct
19 Correct 1 ms 2384 KB Output is correct
20 Correct 5 ms 2660 KB Output is correct
21 Correct 1 ms 2384 KB Output is correct
22 Correct 1 ms 2384 KB Output is correct
23 Correct 1 ms 2384 KB Output is correct
24 Correct 2 ms 2384 KB Output is correct
25 Correct 2 ms 2640 KB Output is correct
26 Correct 4 ms 2384 KB Output is correct
27 Correct 3 ms 2384 KB Output is correct
28 Incorrect 2 ms 2552 KB Output isn't correct
29 Halted 0 ms 0 KB -