제출 #965335

#제출 시각아이디문제언어결과실행 시간메모리
965335MisterReaperHarbingers (CEOI09_harbingers)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using i64 = long long; constexpr int maxN = 1E5 + 5; constexpr i64 INF = 1E18; int N; std::vector<std::pair<int, int>> adj[maxN]; int S[maxN], V[maxN], par[maxN], w[maxN]; i64 dp[maxN]; void dfs(int v) { i64 d = 0; int u = v; while(u != 1) { d += w[u]; u = par[u]; dp[v] = std::min(dp[v], dp[u] + 1LL * d * V[v] + S[v]); } for(auto [u, w] : adj[v]) { if(u == par[v]) { continue; } ::w[u] = w; par[u] = v; dfs(u); } } signed main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); #ifndef LOCAL freopen("harbingers.in", 'r', stdin); freopen("harbingers.out", 'w', stdout); #endif std::cin >> N; for(int i = 1; i <= N - 1; i++) { int A, B, W; std::cin >> A >> B >> W; adj[A].emplace_back(B, W); adj[B].emplace_back(A, W); } for(int i = 2; i <= N; i++) { std::cin >> S[i] >> V[i]; } std::fill_n(&dp[1], N, INF); dp[1] = 0; par[1] = 1; dfs(1); for(int i = 2; i <= N; i++) { std::cout << dp[i] << " \n"[i == N]; } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

harbingers.cpp: In function 'int main()':
harbingers.cpp:35:34: error: invalid conversion from 'char' to 'const char*' [-fpermissive]
   35 |         freopen("harbingers.in", 'r', stdin);
      |                                  ^~~
      |                                  |
      |                                  char
In file included from /usr/include/c++/10/cstdio:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:46,
                 from harbingers.cpp:1:
/usr/include/stdio.h:253:32: note:   initializing argument 2 of 'FILE* freopen(const char*, const char*, FILE*)'
  253 |         const char *__restrict __modes,
      |         ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
harbingers.cpp:36:35: error: invalid conversion from 'char' to 'const char*' [-fpermissive]
   36 |         freopen("harbingers.out", 'w', stdout);
      |                                   ^~~
      |                                   |
      |                                   char
In file included from /usr/include/c++/10/cstdio:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:46,
                 from harbingers.cpp:1:
/usr/include/stdio.h:253:32: note:   initializing argument 2 of 'FILE* freopen(const char*, const char*, FILE*)'
  253 |         const char *__restrict __modes,
      |         ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
harbingers.cpp:35:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |         freopen("harbingers.in", 'r', stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
harbingers.cpp:36:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |         freopen("harbingers.out", 'w', stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~