답안 #1075956

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1075956 2024-08-26T10:02:41 Z alexdd Jakarta Skyscrapers (APIO15_skyscraper) C++17
100 / 100
811 ms 3952 KB
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int LIM = 0;
int n,m;
int b[30005],p[30005];
set<pair<int,int>> ofrest[LIM+2][LIM+2][2];
int dist[300005];
priority_queue<pair<int,int>> pq;
vector<int> onpoz[30005];
signed main()
{
    cin>>n>>m;
    for(int i=0;i<n;i++)
        dist[i]=INF;
    for(int i=0;i<m;i++)
    {
        cin>>b[i]>>p[i];
        onpoz[b[i]].push_back(i);
    }
    dist[b[0]]=0;
    for(int i=0;i<n;i++)
    {
        for(int j=1;j<=LIM;j++)
        {
            ofrest[j][i%j][0].insert({dist[i]-i/j,i});
            ofrest[j][i%j][1].insert({dist[i]+i/j,i});
        }
    }
    pq.push({0,b[0]});
    while(!pq.empty())
    {
        int cdist = -pq.top().first;
        int poz = pq.top().second;
        pq.pop();
        if(dist[poz]!=cdist)
            continue;
        for(int id:onpoz[poz])
        {
            assert(b[id]==poz);
            if(p[id] > LIM)
            {
                for(int i=1;poz+i*p[id]<n;i++)
                {
                    int cpoz = poz+i*p[id];
                    if(dist[cpoz] > dist[poz]+i)
                    {
                        dist[cpoz] = dist[poz]+i;
                        pq.push({-dist[cpoz],cpoz});
                    }
                }
                for(int i=1;poz-i*p[id]>=0;i++)
                {
                    int cpoz = poz-i*p[id];
                    if(dist[cpoz] > dist[poz]+i)
                    {
                        dist[cpoz] = dist[poz]+i;
                        pq.push({-dist[cpoz],cpoz});
                    }
                }
            }
            else
            {

            }
        }
    }
    if(dist[b[1]]==INF)
        cout<<-1;
    else
        cout<<dist[b[1]];
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1112 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 1112 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 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 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 1112 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 2 ms 1116 KB Output is correct
12 Correct 1 ms 1144 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
14 Correct 1 ms 1164 KB Output is correct
15 Correct 1 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 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 1 ms 1116 KB Output is correct
6 Correct 1 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 1 ms 1128 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 1 ms 1116 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
14 Correct 1 ms 1116 KB Output is correct
15 Correct 1 ms 1116 KB Output is correct
16 Correct 2 ms 1112 KB Output is correct
17 Correct 1 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 4 ms 1296 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 2 ms 1116 KB Output is correct
26 Correct 4 ms 1116 KB Output is correct
27 Correct 3 ms 1224 KB Output is correct
28 Correct 2 ms 1116 KB Output is correct
29 Correct 1 ms 1116 KB Output is correct
30 Correct 1 ms 1112 KB Output is correct
31 Correct 1 ms 1112 KB Output is correct
32 Correct 1 ms 1116 KB Output is correct
33 Correct 2 ms 1364 KB Output is correct
34 Correct 2 ms 1372 KB Output is correct
# 결과 실행 시간 메모리 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 1148 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 1152 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 1 ms 1116 KB Output is correct
13 Correct 1 ms 1112 KB Output is correct
14 Correct 1 ms 1112 KB Output is correct
15 Correct 1 ms 1116 KB Output is correct
16 Correct 1 ms 1116 KB Output is correct
17 Correct 1 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 4 ms 1116 KB Output is correct
21 Correct 1 ms 1112 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 2 ms 1116 KB Output is correct
26 Correct 4 ms 1116 KB Output is correct
27 Correct 4 ms 1112 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 1116 KB Output is correct
34 Correct 2 ms 1368 KB Output is correct
35 Correct 9 ms 1656 KB Output is correct
36 Correct 3 ms 1116 KB Output is correct
37 Correct 11 ms 1636 KB Output is correct
38 Correct 13 ms 1880 KB Output is correct
39 Correct 10 ms 1880 KB Output is correct
40 Correct 11 ms 1996 KB Output is correct
41 Correct 11 ms 1880 KB Output is correct
42 Correct 48 ms 1732 KB Output is correct
43 Correct 50 ms 1628 KB Output is correct
44 Correct 47 ms 1712 KB Output is correct
45 Correct 9 ms 1884 KB Output is correct
46 Correct 10 ms 1884 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1112 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 1 ms 1112 KB Output is correct
8 Correct 1 ms 1368 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 1 ms 1172 KB Output is correct
13 Correct 1 ms 1204 KB Output is correct
14 Correct 1 ms 1112 KB Output is correct
15 Correct 1 ms 1116 KB Output is correct
16 Correct 1 ms 1116 KB Output is correct
17 Correct 1 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 5 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 2 ms 1116 KB Output is correct
25 Correct 2 ms 1116 KB Output is correct
26 Correct 4 ms 1116 KB Output is correct
27 Correct 3 ms 1216 KB Output is correct
28 Correct 1 ms 1116 KB Output is correct
29 Correct 2 ms 1184 KB Output is correct
30 Correct 1 ms 1116 KB Output is correct
31 Correct 1 ms 1112 KB Output is correct
32 Correct 1 ms 1116 KB Output is correct
33 Correct 2 ms 1156 KB Output is correct
34 Correct 2 ms 1368 KB Output is correct
35 Correct 12 ms 1628 KB Output is correct
36 Correct 2 ms 1112 KB Output is correct
37 Correct 8 ms 1628 KB Output is correct
38 Correct 11 ms 1884 KB Output is correct
39 Correct 10 ms 1936 KB Output is correct
40 Correct 11 ms 1772 KB Output is correct
41 Correct 11 ms 1872 KB Output is correct
42 Correct 48 ms 1628 KB Output is correct
43 Correct 49 ms 1624 KB Output is correct
44 Correct 47 ms 1628 KB Output is correct
45 Correct 9 ms 1880 KB Output is correct
46 Correct 10 ms 1868 KB Output is correct
47 Correct 17 ms 2520 KB Output is correct
48 Correct 10 ms 1884 KB Output is correct
49 Correct 9 ms 1868 KB Output is correct
50 Correct 7 ms 1884 KB Output is correct
51 Correct 29 ms 3556 KB Output is correct
52 Correct 24 ms 2844 KB Output is correct
53 Correct 16 ms 3036 KB Output is correct
54 Correct 2 ms 1372 KB Output is correct
55 Correct 2 ms 1412 KB Output is correct
56 Correct 764 ms 2988 KB Output is correct
57 Correct 38 ms 3544 KB Output is correct
58 Correct 783 ms 1972 KB Output is correct
59 Correct 684 ms 2088 KB Output is correct
60 Correct 811 ms 2068 KB Output is correct
61 Correct 660 ms 2108 KB Output is correct
62 Correct 23 ms 2760 KB Output is correct
63 Correct 26 ms 3032 KB Output is correct
64 Correct 28 ms 2876 KB Output is correct
65 Correct 28 ms 2880 KB Output is correct
66 Correct 38 ms 3928 KB Output is correct
67 Correct 39 ms 3952 KB Output is correct