Submission #112307

#TimeUsernameProblemLanguageResultExecution timeMemory
112307Mercenary꿈 (IOI13_dreaming)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define taskname "TEST" #define pb push_back typedef long double ld; typedef long long ll; const int maxn = 1e5 + 5; int n , m,l; ll now = 0; vector<ll> v; typedef pair<int,int> tpair; #define mp make_pair ll h[maxn]; ll h1[maxn]; vector<tpair> adj[maxn]; int vis[maxn]; ll res = 0; void DFS(int u , int par){ vis[u] = 1; multiset<ll,greater<ll>> s; for(auto c : adj[u]){ if(c.first == par)continue; DFS(c.first , u); h[u] = max(h[u],h[c.first]+c.second); s.insert(h[c.first]+c.second); } for(auto c : adj[u]){ if(c.first == par)continue; s.erase(s.find(h[c.first]+c.second)); if(s.size())h1[c.first] = *s.begin(); s.insert(h[c.first]+c.second); } } void DFS1(int u , int par , ll cur){ now = min(now,max(h[u],cur)); res = max(res,max(h[u],cur)); for(auto c : adj[u]){ if(c.first == par)continue; DFS1(c.first,u,max(cur,h1[c.first])+c.second); } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); if(fopen(taskname".INP","r")) freopen(taskname".INP", "r",stdin) , freopen(taskname".OUT", "w",stdout); cin >> n >> m >> l; for(int i = 1 ; i <= m ; ++i){ int u , v , w;cin >> u >> v >> w; adj[u].pb(mp(v,w)); adj[v].pb(mp(u,w)); } for(int i = 0 ; i < n ; ++i){ if(vis[i] == 0){ now = 1e18; DFS(i , -1); DFS1(i , - 1, 0); v.pb(now); // cout << now << endl; } } sort(v.begin(),v.end(),greater<ll>()); if(v.size() == 1)cout << max(res,v[0]); else if(v.size() == 2)cout << max(v[0] + v[1] + l,res); else cout << max(max(v[0]+v[1]+l,v[1]+v[2]+2*l),res); }

Compilation message (stderr)

dreaming.cpp: In function 'int main()':
dreaming.cpp:51:44: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
         freopen(taskname".INP", "r",stdin) ,
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
         freopen(taskname".OUT", "w",stdout);
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
dreaming.cpp:51:44: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
/tmp/ccfvr2Ky.o: In function `main':
dreaming.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccw0DZ9g.o:grader.c:(.text.startup+0x0): first defined here
/tmp/ccw0DZ9g.o: In function `main':
grader.c:(.text.startup+0xa2): undefined reference to `travelTime'
collect2: error: ld returned 1 exit status