제출 #964701

#제출 시각아이디문제언어결과실행 시간메모리
9647018pete8City Mapping (NOI18_citymapping)C++17
0 / 100
14 ms604 KiB
#include "citymapping.h" #include<iostream> #include<stack> #include<map> #include<vector> #include<string> #include<unordered_map> #include <queue> #include<cstring> #include<limits.h> #include <cassert> #include<cmath> #include<set> #include<algorithm> #include <iomanip> #include<numeric> //gcd(a,b) #include<bitset> #include <cstdlib> #include <cstdint> using namespace std; #define ll long long #define f first //#define endl "\n" #define s second #define pii pair<int,int> #define ppii pair<int,pii> #define vi vector<int> #define pb push_back #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define F(n) for(int i=0;i<n;i++) #define lb lower_bound #define ub upper_bound #define fastio ios::sync_with_stdio(false);cin.tie(NULL); #pragma GCC optimize ("03,unroll-loops") using namespace std; #define int long long //#define double long double const int mxn=2e3,inf=1e18; vector<int>on; int sz[mxn+10],del[mxn+10],D[mxn+10],up[mxn+10]; vector<pair<pii,int>>e; vector<int>adj[mxn+10]; vector<int>von; int cnt=0; int n; void getsz(int cur,int p){ sz[cur]=1; cnt++; on.pb(cur); for(auto i:adj[cur]){ if(del[i]||i==p)continue; up[i]=cur; getsz(i,cur); sz[cur]+=sz[i]; } } int qnode,last; void solve(int node){ on.clear(); cnt=0; getsz(node,-1); pii ed={inf,-1}; up[node]=-1; if(on.size()==1){ int y=get_distance(node,qnode); e.pb({{qnode,node},y}); adj[node].pb(qnode); adj[qnode].pb(node); return; } for(auto i:on)if(sz[i]<=(cnt/2))ed=min(ed,{abs((cnt/2)-sz[i]),i}); int x=get_distance(ed.s,qnode); if(D[qnode]==D[ed.s]+x){ del[up[ed.s]]=1; for(int i=1;i<=n;i++)D[i]-=D[ed.s]; solve(ed.s); } else{ del[ed.s]=1; solve(node); } } void find_roads(int32_t N, int32_t q, int32_t A[], int32_t B[], int32_t W[]){ n=N; srand(time(NULL)); int st=rand()%n; st++; vector<pii>o; for(int i=1;i<=n;i++)if(i!=st)o.pb({get_distance(i,st),i}); sort(all(o)); for(auto i:o){ qnode=i.s; for(int i=1;i<=n;i++)del[i]=0; D[st]=0; for(auto i:o)D[i.s]=i.f; solve(st); } for(int i=0;i<e.size();i++)A[i]=e[i].f.f,B[i]=e[i].f.s,W[i]=e[i].s; return; }

컴파일 시 표준 에러 (stderr) 메시지

citymapping.cpp: In function 'void find_roads(int32_t, int32_t, int32_t*, int32_t*, int32_t*)':
citymapping.cpp:99:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<std::pair<long long int, long long int>, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   99 |  for(int i=0;i<e.size();i++)A[i]=e[i].f.f,B[i]=e[i].f.s,W[i]=e[i].s;
      |              ~^~~~~~~~~
#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...