Submission #586470

#TimeUsernameProblemLanguageResultExecution timeMemory
586470krit3379City Mapping (NOI18_citymapping)C++17
32 / 100
60 ms24660 KiB
#include<bits/stdc++.h> #include "citymapping.h" using namespace std; #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #define N 1005 struct A{ int a,b,w; }; long long dis[N][N],dis1[N],ma,id,last,last_node; vector<pair<long long,long long>> v,g[N]; vector<A> edge; bitset<N> vis; void dfs(int s,int f){ vis[s]=true; for(auto [x,w]:g[s]){ if(vis[x])continue; if(!f||dis[f][s]+dis[s][x]==dis[f][x])dfs(x,s),edge.push_back({s,x,w}); } } void find_roads(int n,int q,int a[], int b[],int w[]){ int i,j; if(q==500000){ for(i=1;i<=n;i++)for(j=i+1;j<=n;j++){ long long x=get_distance(i,j); dis[i][j]=dis[j][i]=x; g[i].push_back({j,x}); g[j].push_back({i,x}); } dfs(1,0); for(i=0;i<edge.size();i++){ a[i]=edge[i].a; b[i]=edge[i].b; w[i]=edge[i].w; } } else if(q==12000){ for(i=2;i<=n;i++)dis1[i]=get_distance(1,i); for(i=1;i<=n;i++)if(dis1[i]>ma)ma=dis1[i],id=i; for(i=1;i<=n;i++)if(i!=id)v.push_back({get_distance(id,i),i}); sort(v.begin(),v.end()); last=0; last_node=id; for(i=0;i<v.size();i++){ a[i]=last_node; b[i]=v[i].second; w[i]=v[i].first-last; last=v[i].first; last_node=v[i].second; } } }

Compilation message (stderr)

citymapping.cpp: In function 'void dfs(int, int)':
citymapping.cpp:21:74: warning: narrowing conversion of 'x' from 'std::tuple_element<0, std::pair<long long int, long long int> >::type' {aka 'long long int'} to 'int' [-Wnarrowing]
   21 |         if(!f||dis[f][s]+dis[s][x]==dis[f][x])dfs(x,s),edge.push_back({s,x,w});
      |                                                                          ^
citymapping.cpp:21:76: warning: narrowing conversion of 'w' from 'std::tuple_element<1, std::pair<long long int, long long int> >::type' {aka 'long long int'} to 'int' [-Wnarrowing]
   21 |         if(!f||dis[f][s]+dis[s][x]==dis[f][x])dfs(x,s),edge.push_back({s,x,w});
      |                                                                            ^
citymapping.cpp: In function 'void find_roads(int, int, int*, int*, int*)':
citymapping.cpp:35:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<A>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         for(i=0;i<edge.size();i++){
      |                 ~^~~~~~~~~~~~
citymapping.cpp:48:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |         for(i=0;i<v.size();i++){
      |                 ~^~~~~~~~~
#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...