답안 #76829

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
76829 2018-09-18T13:48:29 Z vex Jakarta Skyscrapers (APIO15_skyscraper) C++14
57 / 100
1000 ms 3188 KB
#include <bits/stdc++.h>
#define maxn 30005
#define pii pair<int,int>
using namespace std;

int n,m;
vector<int>p[maxn];
priority_queue<pii>pq;
int dis[maxn];
bool bio[maxn];

bool cmp(int x,int y)
{
    return x>y;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    cin>>n>>m;
    int s;
    int e;
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        p[x].push_back(y);
        if(i==0)s=x;
        if(i==1)e=x;
    }

    if(e==s)
    {
        cout<<"0"<<endl;
        return 0;
    }

    for(int i=0;i<n;i++)
    {
        dis[i]=maxn*maxn+55;
        bio[i]=false;
    }
    pq.push({0,s});
    dis[s]=0;

    while(!pq.empty())
    {
        int v=pq.top().second;
        pq.pop();
      	if(v==e)
        {
          cout<<dis[e]<<endl;
          return 0;
        }
        if(bio[v])continue;
        bio[v]=true;

        for(auto x:p[v])
        {
            for(int i=v%x;i<n;i+=x)
            {
                if(dis[i]>dis[v]+(abs(i-v))/x)
                {
                    dis[i]=dis[v]+(abs(i-v))/x;
                    pq.push({-dis[i],i});
                }
            }
        }
    }

    if(dis[e]<maxn*maxn+1)cout<<dis[e]<<endl;
    else cout<<"-1"<<endl;
    return 0;
}

Compilation message

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:53:8: warning: 'e' may be used uninitialized in this function [-Wmaybe-uninitialized]
        if(v==e)
        ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1016 KB Output is correct
2 Correct 2 ms 1148 KB Output is correct
3 Correct 2 ms 1148 KB Output is correct
4 Correct 3 ms 1148 KB Output is correct
5 Correct 3 ms 1148 KB Output is correct
6 Correct 2 ms 1272 KB Output is correct
7 Correct 3 ms 1308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1308 KB Output is correct
2 Correct 3 ms 1308 KB Output is correct
3 Correct 3 ms 1308 KB Output is correct
4 Correct 2 ms 1308 KB Output is correct
5 Correct 2 ms 1308 KB Output is correct
6 Correct 2 ms 1308 KB Output is correct
7 Correct 3 ms 1308 KB Output is correct
8 Correct 3 ms 1308 KB Output is correct
9 Correct 3 ms 1308 KB Output is correct
10 Correct 3 ms 1308 KB Output is correct
11 Correct 3 ms 1308 KB Output is correct
12 Correct 3 ms 1308 KB Output is correct
13 Correct 4 ms 1308 KB Output is correct
14 Correct 3 ms 1364 KB Output is correct
15 Correct 3 ms 1364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1364 KB Output is correct
2 Correct 3 ms 1364 KB Output is correct
3 Correct 3 ms 1364 KB Output is correct
4 Correct 3 ms 1364 KB Output is correct
5 Correct 2 ms 1364 KB Output is correct
6 Correct 2 ms 1364 KB Output is correct
7 Correct 3 ms 1364 KB Output is correct
8 Correct 3 ms 1364 KB Output is correct
9 Correct 2 ms 1364 KB Output is correct
10 Correct 3 ms 1364 KB Output is correct
11 Correct 3 ms 1364 KB Output is correct
12 Correct 3 ms 1364 KB Output is correct
13 Correct 4 ms 1364 KB Output is correct
14 Correct 3 ms 1364 KB Output is correct
15 Correct 3 ms 1364 KB Output is correct
16 Correct 3 ms 1364 KB Output is correct
17 Correct 3 ms 1404 KB Output is correct
18 Correct 3 ms 1404 KB Output is correct
19 Correct 3 ms 1404 KB Output is correct
20 Correct 22 ms 1404 KB Output is correct
21 Correct 3 ms 1404 KB Output is correct
22 Correct 3 ms 1404 KB Output is correct
23 Correct 4 ms 1404 KB Output is correct
24 Correct 4 ms 1404 KB Output is correct
25 Correct 4 ms 1404 KB Output is correct
26 Correct 3 ms 1404 KB Output is correct
27 Correct 3 ms 1404 KB Output is correct
28 Correct 3 ms 1404 KB Output is correct
29 Correct 5 ms 1404 KB Output is correct
30 Correct 4 ms 1404 KB Output is correct
31 Correct 4 ms 1456 KB Output is correct
32 Correct 3 ms 1508 KB Output is correct
33 Correct 5 ms 1508 KB Output is correct
34 Correct 4 ms 1548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1548 KB Output is correct
2 Correct 2 ms 1548 KB Output is correct
3 Correct 3 ms 1548 KB Output is correct
4 Correct 2 ms 1548 KB Output is correct
5 Correct 3 ms 1548 KB Output is correct
6 Correct 3 ms 1548 KB Output is correct
7 Correct 3 ms 1548 KB Output is correct
8 Correct 3 ms 1548 KB Output is correct
9 Correct 2 ms 1548 KB Output is correct
10 Correct 3 ms 1548 KB Output is correct
11 Correct 3 ms 1548 KB Output is correct
12 Correct 3 ms 1548 KB Output is correct
13 Correct 4 ms 1548 KB Output is correct
14 Correct 3 ms 1548 KB Output is correct
15 Correct 3 ms 1548 KB Output is correct
16 Correct 3 ms 1548 KB Output is correct
17 Correct 3 ms 1548 KB Output is correct
18 Correct 3 ms 1548 KB Output is correct
19 Correct 3 ms 1548 KB Output is correct
20 Correct 22 ms 1548 KB Output is correct
21 Correct 3 ms 1548 KB Output is correct
22 Correct 3 ms 1548 KB Output is correct
23 Correct 3 ms 1548 KB Output is correct
24 Correct 4 ms 1548 KB Output is correct
25 Correct 3 ms 1548 KB Output is correct
26 Correct 3 ms 1548 KB Output is correct
27 Correct 3 ms 1548 KB Output is correct
28 Correct 3 ms 1548 KB Output is correct
29 Correct 4 ms 1548 KB Output is correct
30 Correct 3 ms 1548 KB Output is correct
31 Correct 4 ms 1548 KB Output is correct
32 Correct 3 ms 1548 KB Output is correct
33 Correct 5 ms 1548 KB Output is correct
34 Correct 4 ms 1548 KB Output is correct
35 Correct 10 ms 1548 KB Output is correct
36 Correct 5 ms 1548 KB Output is correct
37 Correct 8 ms 1660 KB Output is correct
38 Correct 13 ms 1788 KB Output is correct
39 Correct 11 ms 1788 KB Output is correct
40 Correct 10 ms 1788 KB Output is correct
41 Correct 15 ms 1788 KB Output is correct
42 Correct 7 ms 1788 KB Output is correct
43 Correct 7 ms 1788 KB Output is correct
44 Correct 298 ms 1788 KB Output is correct
45 Correct 12 ms 1788 KB Output is correct
46 Correct 11 ms 1788 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1788 KB Output is correct
2 Correct 3 ms 1788 KB Output is correct
3 Correct 2 ms 1788 KB Output is correct
4 Correct 3 ms 1788 KB Output is correct
5 Correct 2 ms 1788 KB Output is correct
6 Correct 3 ms 1788 KB Output is correct
7 Correct 2 ms 1788 KB Output is correct
8 Correct 3 ms 1788 KB Output is correct
9 Correct 3 ms 1788 KB Output is correct
10 Correct 3 ms 1788 KB Output is correct
11 Correct 3 ms 1788 KB Output is correct
12 Correct 3 ms 1788 KB Output is correct
13 Correct 4 ms 1788 KB Output is correct
14 Correct 3 ms 1788 KB Output is correct
15 Correct 3 ms 1788 KB Output is correct
16 Correct 3 ms 1788 KB Output is correct
17 Correct 4 ms 1788 KB Output is correct
18 Correct 3 ms 1788 KB Output is correct
19 Correct 3 ms 1788 KB Output is correct
20 Correct 22 ms 1788 KB Output is correct
21 Correct 3 ms 1788 KB Output is correct
22 Correct 3 ms 1788 KB Output is correct
23 Correct 3 ms 1788 KB Output is correct
24 Correct 5 ms 1788 KB Output is correct
25 Correct 3 ms 1788 KB Output is correct
26 Correct 3 ms 1788 KB Output is correct
27 Correct 3 ms 1788 KB Output is correct
28 Correct 4 ms 1788 KB Output is correct
29 Correct 4 ms 1788 KB Output is correct
30 Correct 3 ms 1788 KB Output is correct
31 Correct 4 ms 1788 KB Output is correct
32 Correct 3 ms 1788 KB Output is correct
33 Correct 5 ms 1788 KB Output is correct
34 Correct 5 ms 1788 KB Output is correct
35 Correct 11 ms 1788 KB Output is correct
36 Correct 4 ms 1788 KB Output is correct
37 Correct 8 ms 1788 KB Output is correct
38 Correct 12 ms 1788 KB Output is correct
39 Correct 10 ms 1788 KB Output is correct
40 Correct 12 ms 1788 KB Output is correct
41 Correct 13 ms 1788 KB Output is correct
42 Correct 8 ms 1788 KB Output is correct
43 Correct 8 ms 1788 KB Output is correct
44 Correct 284 ms 1788 KB Output is correct
45 Correct 12 ms 1788 KB Output is correct
46 Correct 14 ms 1788 KB Output is correct
47 Correct 14 ms 2292 KB Output is correct
48 Correct 9 ms 2292 KB Output is correct
49 Correct 9 ms 2292 KB Output is correct
50 Correct 7 ms 2292 KB Output is correct
51 Correct 23 ms 3188 KB Output is correct
52 Correct 26 ms 3188 KB Output is correct
53 Correct 14 ms 3188 KB Output is correct
54 Correct 5 ms 3188 KB Output is correct
55 Correct 5 ms 3188 KB Output is correct
56 Execution timed out 1078 ms 3188 KB Time limit exceeded
57 Halted 0 ms 0 KB -