Submission #962102

#TimeUsernameProblemLanguageResultExecution timeMemory
962102n3rm1nDreaming (IOI13_dreaming)C++17
0 / 100
1035 ms13208 KiB
#include<bits/stdc++.h> #include "dreaming.h" using namespace std; const int MAXN = 1e5 + 10; vector < pair < int, int > > g[MAXN]; int mark[MAXN]; int used[MAXN]; void dfs0(int beg) { mark[beg] = 1; used[beg] = 1; int nb; for (int i = 0; i < g[beg].size(); ++ i) { nb = g[beg][i].first; if(!used[nb]) dfs0(nb); } } int maxdist = 0; int dfs(int beg) { used[beg] = 1; int nb, distt; int maxx = 0; for (int i = 0; i < g[beg].size(); ++ i) { nb = g[beg][i].first; distt = g[beg][i].second; if(!used[nb])maxx = max(maxx, dfs(nb)+distt); } return maxx; } int travelTime(int N,int M, int L, int A[],int B[], int T[]) { for (int i = 0; i < M; ++ i) { g[A[i]].push_back(make_pair(B[i], T[i])); g[B[i]].push_back(make_pair(A[i], T[i])); } int n = N; dfs0(1); int marked1 = 0, marked0 = 0; int mindist1 = 1e17, mindist2 = 1e17; int currmax; int index1 = 0, index2 = 0; for (int i = 1; i <= n; ++ i) { if(mark[i]) { memset(used, 0 ,sizeof(used)); currmax = dfs(i); if(currmax < mindist1) { mindist1 = currmax; index1 = i; } } else { memset(used, 0 ,sizeof(used)); currmax = dfs(i); if(currmax < mindist2) { mindist2 = currmax; index2 = i; } } } g[index1].push_back(make_pair(index2, L)); g[index2].push_back(make_pair(index1, L)); int ans = 0; for (int i = 1; i <= n; ++ i) { memset(used, 0, sizeof(used)); ans = max(ans, dfs(i)); } return ans; }

Compilation message (stderr)

dreaming.cpp: In function 'void dfs0(int)':
dreaming.cpp:13:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     for (int i = 0; i < g[beg].size(); ++ i)
      |                     ~~^~~~~~~~~~~~~~~
dreaming.cpp: In function 'int dfs(int)':
dreaming.cpp:26:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for (int i = 0; i < g[beg].size(); ++ i)
      |                     ~~^~~~~~~~~~~~~~~
dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:44:20: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+17' to '2147483647' [-Woverflow]
   44 |     int mindist1 = 1e17, mindist2 = 1e17;
      |                    ^~~~
dreaming.cpp:44:37: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+17' to '2147483647' [-Woverflow]
   44 |     int mindist1 = 1e17, mindist2 = 1e17;
      |                                     ^~~~
dreaming.cpp:43:9: warning: unused variable 'marked1' [-Wunused-variable]
   43 |     int marked1 = 0, marked0 = 0;
      |         ^~~~~~~
dreaming.cpp:43:22: warning: unused variable 'marked0' [-Wunused-variable]
   43 |     int marked1 = 0, marked0 = 0;
      |                      ^~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...