답안 #602994

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
602994 2022-07-23T13:55:00 Z BT21tata Jakarta Skyscrapers (APIO15_skyscraper) C++17
36 / 100
1000 ms 33540 KB
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// #pragma GCC target ("avx,avx2,fma")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define SPEED ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0)
#define rall(v) (v).rbegin(),(v).rend()
#define all(v) (v).begin(),(v).end()
#define setp fixed<<setprecision
#define OK cerr<<"OK"<<endl<<flush
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define F first
#define S second
#define y0 jahdakdh
#define y1 jahsadakdakdh
#define endl '\n'
const ll MOD=1e9+7;
const ll mod=(1ll<<31)-1;
const ld eps=1e-8;
using namespace std;
mt19937 rng(std::chrono::system_clock::now().time_since_epoch().count());

int n, m, x[30005], pos[30005], pw[30005];
priority_queue<pii>q;
bool used[30005];
ll dis[30005];
vector<pii> g[30005];

int main()
{
    SPEED;
    memset(x, -1, sizeof(x));
    cin>>n>>m;
    for(int i=0; i<m; i++)
    {
        int b, p;
        cin>>b>>p;
        pos[i]=b;
        pw[i]=p;
        x[b]=i;
    }
    for(int i=0; i<m; i++)
    {
        for(int j=0; j<m; j++)
        {
            if(i==j) continue;
            if(abs(pos[i]-pos[j])%pw[i]==0) g[i].pb({j, abs(pos[i]-pos[j])/pw[i]});
        }
    }
    memset(dis, 63, sizeof(dis));
    q.push({0,0});
    dis[0]=0;
    while(!q.empty())
    {
        int s=q.top().S;
        q.pop();
        if(used[s]) continue;
        used[s]=1;
        for(pii u : g[s])
        {
            if(dis[s]+u.S<dis[u.F])
            {
                dis[u.F]=dis[s]+u.S;
                q.push({-dis[u.F], u.F});
            }
        }
    }
    if(dis[1]>1e9) cout<<-1;
    else cout<<dis[1];
    return 0;
}

/*

5 3 
0 2 
1 1 
4 1
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1364 KB Output is correct
2 Correct 1 ms 1364 KB Output is correct
3 Correct 1 ms 1364 KB Output is correct
4 Correct 1 ms 1364 KB Output is correct
5 Correct 1 ms 1364 KB Output is correct
6 Correct 1 ms 1364 KB Output is correct
7 Correct 1 ms 1364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1280 KB Output is correct
2 Correct 1 ms 1364 KB Output is correct
3 Correct 2 ms 1364 KB Output is correct
4 Correct 1 ms 1364 KB Output is correct
5 Correct 2 ms 1288 KB Output is correct
6 Correct 1 ms 1288 KB Output is correct
7 Correct 1 ms 1288 KB Output is correct
8 Correct 1 ms 1364 KB Output is correct
9 Correct 1 ms 1364 KB Output is correct
10 Correct 2 ms 1492 KB Output is correct
11 Correct 27 ms 3568 KB Output is correct
12 Correct 55 ms 33332 KB Output is correct
13 Correct 55 ms 33520 KB Output is correct
14 Correct 25 ms 2884 KB Output is correct
15 Correct 28 ms 2828 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1364 KB Output is correct
2 Correct 1 ms 1364 KB Output is correct
3 Correct 1 ms 1292 KB Output is correct
4 Correct 1 ms 1364 KB Output is correct
5 Correct 1 ms 1364 KB Output is correct
6 Correct 1 ms 1284 KB Output is correct
7 Correct 1 ms 1364 KB Output is correct
8 Correct 1 ms 1284 KB Output is correct
9 Correct 1 ms 1364 KB Output is correct
10 Correct 2 ms 1492 KB Output is correct
11 Correct 25 ms 3548 KB Output is correct
12 Correct 61 ms 33364 KB Output is correct
13 Correct 58 ms 33476 KB Output is correct
14 Correct 23 ms 2832 KB Output is correct
15 Correct 22 ms 2908 KB Output is correct
16 Correct 5 ms 1620 KB Output is correct
17 Correct 18 ms 1972 KB Output is correct
18 Correct 6 ms 1364 KB Output is correct
19 Correct 2 ms 1308 KB Output is correct
20 Correct 55 ms 33540 KB Output is correct
21 Correct 9 ms 1492 KB Output is correct
22 Correct 4 ms 1364 KB Output is correct
23 Correct 7 ms 1364 KB Output is correct
24 Correct 20 ms 1560 KB Output is correct
25 Correct 20 ms 1536 KB Output is correct
26 Correct 51 ms 30468 KB Output is correct
27 Correct 55 ms 31332 KB Output is correct
28 Correct 22 ms 1612 KB Output is correct
29 Correct 4 ms 1680 KB Output is correct
30 Correct 1 ms 1364 KB Output is correct
31 Correct 3 ms 1412 KB Output is correct
32 Correct 3 ms 1364 KB Output is correct
33 Correct 28 ms 2792 KB Output is correct
34 Correct 26 ms 2892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1288 KB Output is correct
2 Correct 1 ms 1364 KB Output is correct
3 Correct 1 ms 1288 KB Output is correct
4 Correct 1 ms 1364 KB Output is correct
5 Correct 1 ms 1364 KB Output is correct
6 Correct 1 ms 1364 KB Output is correct
7 Correct 1 ms 1288 KB Output is correct
8 Correct 1 ms 1364 KB Output is correct
9 Correct 1 ms 1288 KB Output is correct
10 Correct 2 ms 1492 KB Output is correct
11 Correct 26 ms 3560 KB Output is correct
12 Correct 61 ms 33280 KB Output is correct
13 Correct 66 ms 33460 KB Output is correct
14 Correct 24 ms 2824 KB Output is correct
15 Correct 23 ms 2892 KB Output is correct
16 Correct 5 ms 1620 KB Output is correct
17 Correct 20 ms 2132 KB Output is correct
18 Correct 6 ms 1364 KB Output is correct
19 Correct 2 ms 1364 KB Output is correct
20 Correct 55 ms 33456 KB Output is correct
21 Correct 8 ms 1420 KB Output is correct
22 Correct 5 ms 1364 KB Output is correct
23 Correct 6 ms 1364 KB Output is correct
24 Correct 20 ms 1588 KB Output is correct
25 Correct 21 ms 1560 KB Output is correct
26 Correct 51 ms 30412 KB Output is correct
27 Correct 52 ms 31396 KB Output is correct
28 Correct 21 ms 1640 KB Output is correct
29 Correct 5 ms 1620 KB Output is correct
30 Correct 2 ms 1364 KB Output is correct
31 Correct 3 ms 1420 KB Output is correct
32 Correct 2 ms 1364 KB Output is correct
33 Correct 25 ms 2900 KB Output is correct
34 Correct 24 ms 2916 KB Output is correct
35 Execution timed out 1087 ms 11880 KB Time limit exceeded
36 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1364 KB Output is correct
2 Correct 1 ms 1364 KB Output is correct
3 Correct 1 ms 1364 KB Output is correct
4 Correct 1 ms 1364 KB Output is correct
5 Correct 1 ms 1292 KB Output is correct
6 Correct 1 ms 1284 KB Output is correct
7 Correct 1 ms 1364 KB Output is correct
8 Correct 1 ms 1364 KB Output is correct
9 Correct 1 ms 1364 KB Output is correct
10 Correct 2 ms 1492 KB Output is correct
11 Correct 24 ms 3620 KB Output is correct
12 Correct 55 ms 33408 KB Output is correct
13 Correct 58 ms 33452 KB Output is correct
14 Correct 25 ms 2820 KB Output is correct
15 Correct 25 ms 2900 KB Output is correct
16 Correct 5 ms 1620 KB Output is correct
17 Correct 18 ms 2004 KB Output is correct
18 Correct 7 ms 1364 KB Output is correct
19 Correct 3 ms 1416 KB Output is correct
20 Correct 56 ms 33508 KB Output is correct
21 Correct 9 ms 1424 KB Output is correct
22 Correct 4 ms 1316 KB Output is correct
23 Correct 6 ms 1424 KB Output is correct
24 Correct 19 ms 1616 KB Output is correct
25 Correct 21 ms 1492 KB Output is correct
26 Correct 53 ms 30488 KB Output is correct
27 Correct 52 ms 31284 KB Output is correct
28 Correct 22 ms 1544 KB Output is correct
29 Correct 5 ms 1620 KB Output is correct
30 Correct 2 ms 1364 KB Output is correct
31 Correct 3 ms 1492 KB Output is correct
32 Correct 3 ms 1364 KB Output is correct
33 Correct 26 ms 2864 KB Output is correct
34 Correct 24 ms 2816 KB Output is correct
35 Execution timed out 1083 ms 12012 KB Time limit exceeded
36 Halted 0 ms 0 KB -