답안 #865420

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
865420 2023-10-24T08:07:10 Z Trisanu_Das Journey (NOI18_journey) C++17
69 / 100
81 ms 39048 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

int n, m, h, vis[10005], dp[10005][405];
vector<pair<int, int> > adj[10005];

void dfs(int u){
  if(u == n - 1) return;
  vis[u] = true;
  for(auto e : adj[u]){
    int v = e.ff, w = e.ss;
    if(v < u) continue;
    if(!vis[v]) dfs(v);
    for(int i = w; i < m; i++){
      dp[u][i] += dp[v][i - w];
      dp[u][i] = min(dp[u][i], 500000001LL);
    }
  }
  for(int i = 1; i < m; i++) {
    dp[u][i] += dp[u][i - 1];
    dp[u][i] = min(dp[u][i], 500000001LL);
  }
}

signed main(){
  cin >> n >> m >> h;
  for(int u = 0; u < n - 1; u++){
    for(int i = 0; i < h; i++){
      int v, w; cin >> v >> w;
      adj[u].pb({v, w});
    }
  }
  dp[n - 1][0] = 1;
  dfs(0);
  for(int i = 0; i < m; i++) cout << dp[0][i] << ' ';
  cout << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2676 KB Output is correct
3 Correct 1 ms 2648 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2648 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2676 KB Output is correct
3 Correct 1 ms 2648 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2648 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Incorrect 81 ms 39048 KB Output isn't correct
8 Halted 0 ms 0 KB -