답안 #1034068

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1034068 2024-07-25T09:27:02 Z DucNguyen2007 Jakarta Skyscrapers (APIO15_skyscraper) C++14
36 / 100
1000 ms 16980 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define fi first
#define se second
const int maxN=3e4+5;
const ll inf=2e18;
int n,m,b[maxN+1],p[maxN+1];
namespace sub4
{
    const int LIMIT=2e3+5;
    int d[LIMIT+1][LIMIT+1];
    struct node
    {
        int u,power;
    };
    deque<node> q;
    void solve()
    {
        for(int i=0;i<LIMIT;i++)
        {
            for(int j=0;j<LIMIT;j++)
            {
                d[i][j]=inf;
            }
        }
        q.push_front({b[0],p[0]});
        d[b[0]][p[0]]=0;
        while(!q.empty())
        {
            node tmp=q.front();
            q.pop_front();
            int u=tmp.u,power=tmp.power;
            //cout<<u<<" "<<power<<'\n';
            if(u==b[1])
            {
                cout<<d[u][power];
                return;
            }
            if(u+power<n)
            {
                if(d[u+power][power]>d[u][power]+1)
                {
                    d[u+power][power]=d[u][power]+1;
                    q.push_back({u+power,power});
                }
            }
            if(u-power>=0)
            {
                if(d[u-power][power]>d[u][power]+1)
                {
                    d[u-power][power]=d[u][power]+1;
                    q.push_back({u-power,power});
                }
            }
            for(int i=0;i<m;i++)
            {
                if(b[i]==u)
                {
                    if(d[u][p[i]]>d[u][power])
                    {
                        d[u][p[i]]=d[u][power];
                        q.push_front({u,p[i]});
                    }
                }
            }
        }
        cout<<-1;
    }
}
int main()
{
    //freopen("","r",stdin);
    //freopen("","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>b[i]>>p[i];
    }
    sub4::solve();
}

Compilation message

skyscraper.cpp: In function 'void sub4::solve()':
skyscraper.cpp:25:25: warning: overflow in conversion from 'long long int' to 'int' changes value from '2000000000000000000' to '1321730048' [-Woverflow]
   25 |                 d[i][j]=inf;
      |                         ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 15964 KB Output is correct
2 Correct 7 ms 15964 KB Output is correct
3 Correct 7 ms 16220 KB Output is correct
4 Correct 7 ms 16188 KB Output is correct
5 Correct 6 ms 16072 KB Output is correct
6 Correct 7 ms 16220 KB Output is correct
7 Correct 6 ms 16020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 16220 KB Output is correct
2 Correct 12 ms 15964 KB Output is correct
3 Correct 7 ms 15964 KB Output is correct
4 Correct 8 ms 15960 KB Output is correct
5 Correct 9 ms 16084 KB Output is correct
6 Correct 7 ms 16076 KB Output is correct
7 Correct 7 ms 16220 KB Output is correct
8 Correct 6 ms 15964 KB Output is correct
9 Correct 7 ms 15964 KB Output is correct
10 Correct 7 ms 16220 KB Output is correct
11 Correct 7 ms 16220 KB Output is correct
12 Correct 8 ms 16220 KB Output is correct
13 Correct 7 ms 16248 KB Output is correct
14 Correct 15 ms 16220 KB Output is correct
15 Correct 10 ms 16256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 15964 KB Output is correct
2 Correct 6 ms 16152 KB Output is correct
3 Correct 7 ms 16216 KB Output is correct
4 Correct 7 ms 15964 KB Output is correct
5 Correct 7 ms 15964 KB Output is correct
6 Correct 7 ms 16084 KB Output is correct
7 Correct 6 ms 15960 KB Output is correct
8 Correct 7 ms 16220 KB Output is correct
9 Correct 8 ms 15964 KB Output is correct
10 Correct 7 ms 16220 KB Output is correct
11 Correct 7 ms 16216 KB Output is correct
12 Correct 7 ms 16220 KB Output is correct
13 Correct 6 ms 16220 KB Output is correct
14 Correct 16 ms 16248 KB Output is correct
15 Correct 10 ms 16220 KB Output is correct
16 Correct 7 ms 16220 KB Output is correct
17 Correct 11 ms 16220 KB Output is correct
18 Correct 6 ms 16176 KB Output is correct
19 Correct 7 ms 16220 KB Output is correct
20 Correct 10 ms 16220 KB Output is correct
21 Correct 7 ms 16220 KB Output is correct
22 Correct 7 ms 16032 KB Output is correct
23 Correct 10 ms 16216 KB Output is correct
24 Correct 15 ms 16220 KB Output is correct
25 Correct 8 ms 16216 KB Output is correct
26 Correct 11 ms 16248 KB Output is correct
27 Correct 13 ms 16220 KB Output is correct
28 Correct 34 ms 16104 KB Output is correct
29 Correct 41 ms 16088 KB Output is correct
30 Correct 10 ms 16220 KB Output is correct
31 Correct 20 ms 15976 KB Output is correct
32 Correct 15 ms 16220 KB Output is correct
33 Correct 170 ms 16220 KB Output is correct
34 Correct 92 ms 16216 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 15964 KB Output is correct
2 Correct 9 ms 15980 KB Output is correct
3 Correct 7 ms 15964 KB Output is correct
4 Correct 7 ms 16156 KB Output is correct
5 Correct 7 ms 16060 KB Output is correct
6 Correct 7 ms 16080 KB Output is correct
7 Correct 7 ms 15964 KB Output is correct
8 Correct 7 ms 16220 KB Output is correct
9 Correct 7 ms 16220 KB Output is correct
10 Correct 7 ms 15960 KB Output is correct
11 Correct 7 ms 16472 KB Output is correct
12 Correct 7 ms 16220 KB Output is correct
13 Correct 7 ms 16240 KB Output is correct
14 Correct 16 ms 16220 KB Output is correct
15 Correct 10 ms 16220 KB Output is correct
16 Correct 7 ms 16220 KB Output is correct
17 Correct 16 ms 16036 KB Output is correct
18 Correct 7 ms 16220 KB Output is correct
19 Correct 7 ms 16220 KB Output is correct
20 Correct 10 ms 16220 KB Output is correct
21 Correct 7 ms 16072 KB Output is correct
22 Correct 7 ms 16116 KB Output is correct
23 Correct 10 ms 16472 KB Output is correct
24 Correct 15 ms 16216 KB Output is correct
25 Correct 8 ms 16220 KB Output is correct
26 Correct 11 ms 16092 KB Output is correct
27 Correct 13 ms 16244 KB Output is correct
28 Correct 36 ms 16220 KB Output is correct
29 Correct 38 ms 15996 KB Output is correct
30 Correct 11 ms 16216 KB Output is correct
31 Correct 27 ms 16220 KB Output is correct
32 Correct 15 ms 16220 KB Output is correct
33 Correct 168 ms 16092 KB Output is correct
34 Correct 93 ms 16220 KB Output is correct
35 Correct 603 ms 16720 KB Output is correct
36 Correct 12 ms 16220 KB Output is correct
37 Correct 207 ms 16476 KB Output is correct
38 Correct 277 ms 16700 KB Output is correct
39 Correct 15 ms 16476 KB Output is correct
40 Correct 84 ms 16684 KB Output is correct
41 Correct 141 ms 16520 KB Output is correct
42 Correct 66 ms 16476 KB Output is correct
43 Correct 99 ms 16476 KB Output is correct
44 Correct 48 ms 16476 KB Output is correct
45 Execution timed out 1042 ms 16720 KB Time limit exceeded
46 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 15964 KB Output is correct
2 Correct 7 ms 16216 KB Output is correct
3 Correct 10 ms 15964 KB Output is correct
4 Correct 7 ms 16084 KB Output is correct
5 Correct 7 ms 15964 KB Output is correct
6 Correct 7 ms 16008 KB Output is correct
7 Correct 7 ms 15960 KB Output is correct
8 Correct 7 ms 15988 KB Output is correct
9 Correct 7 ms 16084 KB Output is correct
10 Correct 7 ms 16216 KB Output is correct
11 Correct 7 ms 16220 KB Output is correct
12 Correct 7 ms 15988 KB Output is correct
13 Correct 7 ms 16220 KB Output is correct
14 Correct 16 ms 16260 KB Output is correct
15 Correct 11 ms 16220 KB Output is correct
16 Correct 7 ms 16220 KB Output is correct
17 Correct 11 ms 16256 KB Output is correct
18 Correct 7 ms 16220 KB Output is correct
19 Correct 7 ms 16220 KB Output is correct
20 Correct 11 ms 16220 KB Output is correct
21 Correct 6 ms 16220 KB Output is correct
22 Correct 7 ms 16116 KB Output is correct
23 Correct 14 ms 16220 KB Output is correct
24 Correct 15 ms 16216 KB Output is correct
25 Correct 8 ms 16120 KB Output is correct
26 Correct 12 ms 16252 KB Output is correct
27 Correct 13 ms 16220 KB Output is correct
28 Correct 34 ms 16216 KB Output is correct
29 Correct 39 ms 16220 KB Output is correct
30 Correct 10 ms 16220 KB Output is correct
31 Correct 21 ms 16220 KB Output is correct
32 Correct 16 ms 16216 KB Output is correct
33 Correct 183 ms 16216 KB Output is correct
34 Correct 91 ms 16240 KB Output is correct
35 Correct 606 ms 16980 KB Output is correct
36 Correct 12 ms 16216 KB Output is correct
37 Correct 208 ms 16476 KB Output is correct
38 Correct 288 ms 16720 KB Output is correct
39 Correct 19 ms 16464 KB Output is correct
40 Correct 82 ms 16708 KB Output is correct
41 Correct 131 ms 16720 KB Output is correct
42 Correct 66 ms 16624 KB Output is correct
43 Correct 93 ms 16628 KB Output is correct
44 Correct 49 ms 16476 KB Output is correct
45 Execution timed out 1035 ms 16728 KB Time limit exceeded
46 Halted 0 ms 0 KB -