답안 #548772

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
548772 2022-04-14T11:47:50 Z jack715 Journey (NOI18_journey) C++14
20 / 100
739 ms 262144 KB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pp pop_back
#define mp make_pair
#define bb back
#define ff first
#define ss second

using namespace std;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, m, h;
    cin >> n >> m >> h;
    vector<vector<pair<int, int> > > path(n, vector<pair<int, int> >(m));
    
    for (int i = 0; i < n-1; i++)
    for (int j = 0; j < h; j++) 
        cin >> path[i][j].ff >> path[i][j].ss;
    
    priority_queue<pair<int, int> > pq;
    pq.push({0, 0});
    vector<int> ans(m+1, 0);

    while (!pq.empty()) {
        int time = pq.top().ff, indx = pq.top().ss;
        pq.pop();
        if (time < -m)
            continue;
        if (indx == n-1) {
            ans[-time]++;
            continue; 
        }

        for (int i = 0; i < h; i++) {
            if (path[indx][i].ff < indx)
                continue;
            for (int j = path[indx][i].ss; j <= m; j++)
                pq.push({time-j, path[indx][i].ff});
        }
    }

    for (int i = 0; i < m; i++)
        cout << ans[i] << ' ';
    cout << '\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 416 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 739 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 416 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Runtime error 739 ms 262144 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 416 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Runtime error 739 ms 262144 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -