제출 #368432

#제출 시각아이디문제언어결과실행 시간메모리
3684321306439119Traffic (IOI10_traffic)C++11
0 / 100
1 ms364 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 LocateCentre(int n, int* p, int* s, int* d){ for(int i = 0; i < n; i++){ A[i] = new node(i, p[i], vector<node*>()); } for(int i = 0; i < n-1; i++){ A[s[i]]->adj.push_back(A[d[i]]); A[d[i]]->adj.push_back(A[s[i]]); } ll res = LLONG_MAX; for(int i = 0; i < n; i++){ res = min(res, root(A[i])); } return res; } /*int main(){ setIO(""); 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);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...