제출 #384035

#제출 시각아이디문제언어결과실행 시간메모리
384035MODDIRace (IOI11_race)C++14
컴파일 에러
0 ms0 KiB
//#include "race.h" #include <bits/stdc++.h> #define ll long long #define pii pair<int,int> #define pll pair<ll,ll> #define vi vector<int> #define vl vector<ll> #define mp make_pair #define pb push_back #define MAX_N 500000 using namespace std; vector<pii> G[200000]; static int N, K; static int H[MAX_N][2]; static int L[MAX_N]; static int solution; ll min(ll a, ll b){ if(a > b) return b; return a; } int best = 1e9; void rec(int node, int cnt_nodes, int path, int parent){ if(path == K){ best = min(best, cnt_nodes); return; } if(cnt_nodes >= best || path > K) return; for(auto next : G[node]){ if(next.first != parent){ rec(next.first, cnt_nodes + 1, path + next.second, node); } } } int best_path(int n, int k, int h[][2], int l[]) { for(int i = 0; i < n-1; i++){ G[h[i][0]].pb(mp(h[i][1], l[i])); G[h[i][1]].pb(mp(h[i][0], l[i])); } for(int i = 0; i < n; i++) rec(i, 0, 0, -1); if(best == 1e9) return -1; return best; } void read_input() { int i; scanf("%d %d",&N,&K); for(i=0; i<N-1; i++) scanf("%d %d %d",&H[i][0],&H[i][1],&L[i]); scanf("%d",&solution); } int main() { int ans; read_input(); ans = best_path(N,K,H,L); if(ans==solution) printf("Correct.\n"); else printf("Incorrect. Returned %d, Expected %d.\n",ans,solution); return 0; }

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

race.cpp: In function 'void read_input()':
race.cpp:52:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   52 |   scanf("%d %d",&N,&K);
      |   ~~~~~^~~~~~~~~~~~~~~
race.cpp:54:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   54 |     scanf("%d %d %d",&H[i][0],&H[i][1],&L[i]);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
race.cpp:56:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   56 |  scanf("%d",&solution);
      |  ~~~~~^~~~~~~~~~~~~~~~
/tmp/ccKGHYzz.o: In function `read_input()':
race.cpp:(.text+0xf0): multiple definition of `read_input()'
/tmp/cc2DR4xq.o:grader.cpp:(.text+0x0): first defined here
/tmp/ccKGHYzz.o: In function `main':
race.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cc2DR4xq.o:grader.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status