제출 #586471

#제출 시각아이디문제언어결과실행 시간메모리
586471krit3379City Mapping (NOI18_citymapping)C++17
32 / 100
79 ms24652 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}); } for(i=1;i<=n;i++)sort(g[i].begin(),g[i].end()); 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; printf("%d %d %d\n",a[i],b[i],w[i]); } } 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; } } }

컴파일 시 표준 에러 (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:36:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<A>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         for(i=0;i<edge.size();i++){
      |                 ~^~~~~~~~~~~~
citymapping.cpp:50: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]
   50 |         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...