답안 #799391

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
799391 2023-07-31T13:43:07 Z RecursiveCo Jakarta Skyscrapers (APIO15_skyscraper) C++14
0 / 100
1 ms 324 KB
// CF template, version 3.0

#include <bits/stdc++.h>

using namespace std;

#define improvePerformance ios_base::sync_with_stdio(false); cin.tie(0)
#define getTest int t; cin >> t
#define eachTest for (int _var=0;_var<t;_var++)
#define get(name) int (name); cin >> (name)
#define out(o) cout << (o)
#define getList(cnt, name) vector<int> (name); for (int _=0;_<(cnt);_++) { get(a); (name).push_back(a); }
#define sortl(name) sort((name).begin(), (name).end())
#define rev(name) reverse((name).begin(), (name).end())
#define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
#define decision(b) if (b){out("YES");}else{out("NO");}

#define int long long int

signed main() {
    improvePerformance;

    get(n);
    get(m);
    vector<pair<int, int>> doges;
    forto(m, i) {
        get(b);
        get(p);
        doges.push_back({b, p});
    }
    vector<vector<pair<int, int>>> adjList(m);
    forto(m, i) {
        forto(m, j) {
            if (i == j) continue;
            int dist = abs(doges[j].first - doges[i].first);
            int jump = doges[i].second;
            if (dist % jump == 0) adjList[i].push_back({j, dist / jump});
        }
    }
    vector<int> shortest(m, 1e18);
    vector<bool> visited(m, false);
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
    pq.push({0, 0});
    while (!pq.empty()) {
        auto top = pq.top();
        int dist = top.first;
        int node = top.second;
        pq.pop();
        if (visited[node]) continue;
        visited[node] = true;
        shortest[node] = min(shortest[node], dist);
        for (auto con: adjList[node]) {
            int dest = con.first;
            int weight = con.second;
            if (!visited[dest]) pq.push({shortest[node] + weight, dest});
        }
    }
    out(shortest[1]);
}

Compilation message

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:10:23: warning: unnecessary parentheses in declaration of 'n' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
skyscraper.cpp:23:5: note: in expansion of macro 'get'
   23 |     get(n);
      |     ^~~
skyscraper.cpp:10:23: warning: unnecessary parentheses in declaration of 'm' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
skyscraper.cpp:24:5: note: in expansion of macro 'get'
   24 |     get(m);
      |     ^~~
skyscraper.cpp:15:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
skyscraper.cpp:26:5: note: in expansion of macro 'forto'
   26 |     forto(m, i) {
      |     ^~~~~
skyscraper.cpp:10:23: warning: unnecessary parentheses in declaration of 'b' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
skyscraper.cpp:27:9: note: in expansion of macro 'get'
   27 |         get(b);
      |         ^~~
skyscraper.cpp:10:23: warning: unnecessary parentheses in declaration of 'p' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
skyscraper.cpp:28:9: note: in expansion of macro 'get'
   28 |         get(p);
      |         ^~~
skyscraper.cpp:15:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
skyscraper.cpp:32:5: note: in expansion of macro 'forto'
   32 |     forto(m, i) {
      |     ^~~~~
skyscraper.cpp:15:35: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
skyscraper.cpp:33:9: note: in expansion of macro 'forto'
   33 |         forto(m, j) {
      |         ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 316 KB Output is correct
4 Incorrect 1 ms 316 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 280 KB Output is correct
2 Correct 0 ms 320 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 0 ms 324 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -