제출 #368423

#제출 시각아이디문제언어결과실행 시간메모리
3684231306439119Traffic (IOI10_traffic)C++11
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pi pair<int, int> #define endl '\n' #define f first #define s second void setIO(string name = "") { ios_base::sync_with_stdio(0); cin.tie(0); if (name.length()) { freopen((name+".in").c_str(), "r", stdin); freopen((name+".out").c_str(), "w", stdout); } } struct node{ int id, person; vector<node*> adj; node(int i, int p, vector<node*> a){ id = i; person = p; adj = a; } }; int n; node* A[1000000]; ll dfs(node* curr, int prev){ ll sum = curr->person; for(node* next : curr->adj){ if(prev != next->id){ sum += dfs(next, curr->id); } } return sum; } ll root(node* root){ ll ret = 0; for(node* next : root->adj){ ret = max(ret, dfs(next, root->id)); } return ret; } int main(){ setIO(""); cin >> n; for(int i = 0; i < n; i++){ int p; cin >> p; A[i] = new node(i, p, vector<node*>()); } for(int i = 1; i < n; i++){ int s, d; cin >> s >> d; A[s]->adj.push_back(A[d]); A[d]->adj.push_back(A[s]); } ll res = LLONG_MAX; for(int i = 0; i < n; i++){ res = min(res, root(A[i])); } cout << res << endl; return 0; }

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

traffic.cpp: In function 'void setIO(std::string)':
traffic.cpp:14:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   14 |         freopen((name+".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
traffic.cpp:15:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   15 |         freopen((name+".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/ccnZe5WZ.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cc1JmozX.o:traffic.cpp:(.text.startup+0x0): first defined here
/tmp/ccnZe5WZ.o: In function `main':
grader.cpp:(.text.startup+0xd9): undefined reference to `LocateCentre(int, int*, int*, int*)'
collect2: error: ld returned 1 exit status