Submission #363035

#TimeUsernameProblemLanguageResultExecution timeMemory
363035eric_xiaoIdeal city (IOI12_city)C++14
0 / 100
1088 ms3348 KiB
#include<bits/stdc++.h> #define ll long long #define pll pair<ll,ll> #define F first #define S second using namespace std; const ll m = 1000000000; set<pll> st,vs; map<pll,ll> L,U,R,D,dis; pll all[100009]; ll X[4] = {0,1,0,-1},Y[4] {1,0,-1,0}; /*k = 0 U k = 1 R k = 2 D k = 4 L*/ ll ans; ll d[100009]; void BFS(pll s) { queue<pll> q; q.push(s); ll i; dis.clear(); dis[s] = 0; while(!q.empty()) { auto u = q.front(); q.pop(); for(i = 0;i < 4;i++) { if(st.count({u.F + X[i],u.S + Y[i]}) && !dis.count({u.F + X[i],u.S + Y[i]})) { dis[{u.F + X[i],u.S + Y[i]}] = dis[u] + 1; q.push({u.F + X[i],u.S + Y[i]}); } } } for(auto a : dis) { ans += a.S; } } int DistanceSum(int N, int *X, int *Y) { ll M,i,j,k; ll xm = 100000000009,ym = 100000000009; for(i = 0;i < N;i++) { all[i] = {X[i],Y[i]}; } sort(all,all+N); for(i = N-1;i >= 0;i--) { all[i].F -= (xm-1); all[i].S -= (ym-1); st.insert(all[i]); } for(i = 0;i < N;i++) { BFS(all[i]); } return (int)ans; }

Compilation message (stderr)

city.cpp: In function 'int DistanceSum(int, int*, int*)':
city.cpp:44:8: warning: unused variable 'M' [-Wunused-variable]
   44 |     ll M,i,j,k;
      |        ^
city.cpp:44:12: warning: unused variable 'j' [-Wunused-variable]
   44 |     ll M,i,j,k;
      |            ^
city.cpp:44:14: warning: unused variable 'k' [-Wunused-variable]
   44 |     ll M,i,j,k;
      |              ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...