Submission #942390

#TimeUsernameProblemLanguageResultExecution timeMemory
942390emad234Dreaming (IOI13_dreaming)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define ll long long #define F first #define S second #define pii pair<int,int> const int mod = 1e9 + 7; const int mxN = 2e5 + 5; using namespace std; vector<vector<pii>>v; vector<int>nums; int mx[mxN]; bool vis[mxN]; int path; int dpD[mxN],dpU[mxN]; void dfs(int u){ vis[u] = 1; for(auto x : v[u]){ if(vis[x.F]) continue; dfs(x.F); dpD[u] = max(dpD[x.F] + x.S,dpD[u]); } } void hfs(int u,int par){ multiset<int>s; for(auto x : v[u]){ if(x.F == par) continue; s.insert(dpD[x.F] + x.S); } for(auto x : v[u]){ if(x.F == par) continue; dpU[x.F] = dpU[u] + x.S; s.erase(s.find(dpD[x.F] + x.S)); if(s.size()) dpU[x.F] = max(dpU[x.F], *(s.rbegin()) + x.S); s.insert(dpD[x.F] + x.S); } for(auto x : v[u]) if(x.F != par) hfs(x.F,u); path = min(path,max(dpD[u],dpU[u])); } int travelTime(int N, int M, int L, int A[], int B[], int T[]) { v.resize(N + 2); for(int i = 0;i < M;i++){ v[A[i]].push_back({B[i],T[i]}); v[B[i]].push_back({A[i],T[i]}); } int mx = 0; for(int i = 0;i < N;i++){ if(!vis[i]){ path = 2e9; dfs(i); hfs(i,-1); if(path > mx){ if(i) nums.push_back(mx + L); mx = path; } else nums.push_back(path + L); } } sort(nums.begin(),nums.end()); // for(auto x : nums) cout<<x<<' '; // cout<<'\n'; int ans = mx; for(int i = 0;i < nums.size();i++){ int num = 0; if(i == nums.size() - 1){ if(i != 0){ num = nums[i] + nums[i - 1]; } } else num = nums[i] + nums[nums.size() - 1]; num = max(num, nums[i] + mx); ans = max(num,ans); } return ans; } // #define MAX_N 100000 // static int A[MAX_N]; // static int B[MAX_N]; // static int T[MAX_N]; // int main() { // int N, M, L, i; // int res; // cin >>N>>M>>L; // for (i = 0; i < M; i++) // cin>>A[i]>>B[i]>>T[i]; // int answer = travelTime(N, M, L, A, B, T); // printf("%d\n", answer); // return 0; // }

Compilation message (stderr)

dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:62:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |     for(int i = 0;i < nums.size();i++){
      |                   ~~^~~~~~~~~~~~~
dreaming.cpp:64:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |         if(i == nums.size() - 1){
      |            ~~^~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/cctedmvm.o: in function `main':
grader.c:(.text.startup+0xd1): undefined reference to `travelTime'
collect2: error: ld returned 1 exit status