답안 #976175

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
976175 2024-05-06T09:10:18 Z SuPythony Jakarta Skyscrapers (APIO15_skyscraper) C++17
10 / 100
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    int n,m; cin>>n>>m;
    vector<pair<int,int>> doges;
    for (int i=0; i<n; i++) {
        int b,p; cin>>b>>p;
        doges.push_back({b,p});
    }
    vector<vector<pair<int,ll>>> al(n,vector<pair<int,ll>>());
    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            if (i==j) continue;
            int d=abs(doges[i].first-doges[j].first);
            if (d%doges[i].second==0) {
                al[i].push_back({j,d/doges[i].second});
            }
            if (d%doges[j].second==0) {
                al[j].push_back({i,d/doges[j].second});
            }
        }
    }
    vector<ll> dist(n,1e18);
    dist[0]=0;
    priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<>> p;
    p.push({0ll,0});
    while (!p.empty()) {
        int t=p.top().second; p.pop();
        for (auto v: al[t]) {
            if (dist[t]+v.second<dist[v.first]) {
                dist[v.first]=dist[t]+v.second;
                p.push({dist[v.first],v.first});
            }
        }
    }
    if (dist[1]==1e18) cout<<-1;
    else cout<<dist[1];
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Incorrect 0 ms 348 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Incorrect 0 ms 348 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Incorrect 1 ms 348 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Incorrect 1 ms 348 KB Output isn't correct
11 Halted 0 ms 0 KB -