Submission #1071461

#TimeUsernameProblemLanguageResultExecution timeMemory
1071461pccSky Walking (IOI19_walk)C++17
Compilation error
0 ms0 KiB
#include "walk.h" #include <bits/stdc++.h> using namespace std; #define _all(T) T.begin(),T.end() #define ll long long #define pii pair<int,int> #define fs first #define sc second #define pll pair<ll,ll> const int mxn = 2e5+10; const ll inf = 1e18; vector<pii> paths[mxn]; vector<int> all; map<pii,int> mp; ll dist[mxn]; int N; namespace DIJKSTRA{ priority_queue<pll,vector<pll>,greater<pll>> pq; bitset<mxn> vis; void GO(){ vis.reset(); for(int i = 0;i<mp.size();i++){ pq.push(pll(dist[i],i)); } while(!pq.empty()){ auto [d,now] = pq.top(); pq.pop(); if(vis[now])continue; //cerr<<now<<":"<<d<<endl; vis[now] = true; for(auto [nxt,w]:paths[now]){ if(vis[nxt])continue; if(d+w<dist[nxt]){ dist[nxt] = d+w; pq.push(pll(d+w,nxt)); } } } return; } } long long min_distance(std::vector<int> x, std::vector<int> H, std::vector<int> l, std::vector<int> r, std::vector<int> y, int s, int g) { all.push_back(0); N = x.size(); for(auto &i:H)all.push_back(i); for(auto &i:y)all.push_back(i); sort(_all(all)); all.resize(unique(_all(all))-all.begin()); for(int i = 0;i<N;i++){ for(int j = 0;j<all.size();j++)mp[pii(i,j)] = mp.size(); } assert(mp.size()<mxn); /* for(auto &i:mp){ cerr<<i.fs.fs<<','<<all[i.fs.sc]<<":"<<i.sc<<endl; } */ for(int i = 0;i<N;i++){ for(int j = 0;j<all.size();j++){ for(int k = j+1;k<all.size();k++){ int a = mp[pii(i,j)],b = mp[pii(i,k)]; paths[a].push_back(pii(b,abs(all[j]-all[k]))); paths[b].push_back(pii(a,abs(all[j]-all[k]))); } } } for(int i = 0;i<l.size();i++){ int s = l[i],e = r[i],h = y[i]; h = lower_bound(_all(all),h)-all.begin(); assert(all[h] == y[i]) pii pre = pii(s,h); for(int j = s+1;j<=e;j++){ if(H[j]<all[h])continue; pii now = pii(j,h); int a = mp[pre],b = mp[now]; assert(x[now.fs]>=x[pre.fs]); paths[a].push_back(pii(b,x[now.fs]-x[pre.fs])); paths[b].push_back(pii(a,x[now.fs]-x[pre.fs])); pre = now; } } fill(dist,dist+mxn,inf); dist[mp[pii(s,0)]] = 0; //cerr<<mp[pii(s,0)]<<','<<mp[pii(g,0)]<<endl; DIJKSTRA::GO(); return dist[mp[pii(g,0)]]; }

Compilation message (stderr)

walk.cpp: In function 'void DIJKSTRA::GO()':
walk.cpp:26:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::map<std::pair<int, int>, int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |   for(int i = 0;i<mp.size();i++){
      |                 ~^~~~~~~~~~
walk.cpp: In function 'long long int min_distance(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, int, int)':
walk.cpp:55:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |   for(int j = 0;j<all.size();j++)mp[pii(i,j)] = mp.size();
      |                 ~^~~~~~~~~~~
walk.cpp:66:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |   for(int j = 0;j<all.size();j++){
      |                 ~^~~~~~~~~~~
walk.cpp:67:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |    for(int k = j+1;k<all.size();k++){
      |                    ~^~~~~~~~~~~
walk.cpp:74:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   74 |  for(int i = 0;i<l.size();i++){
      |                ~^~~~~~~~~
walk.cpp:6:13: error: expected ';' before 'pair'
    6 | #define pii pair<int,int>
      |             ^~~~
walk.cpp:78:3: note: in expansion of macro 'pii'
   78 |   pii pre = pii(s,h);
      |   ^~~
walk.cpp:82:15: error: 'pre' was not declared in this scope
   82 |    int a = mp[pre],b = mp[now];
      |               ^~~
walk.cpp:84:27: error: 'b' was not declared in this scope
   84 |    paths[a].push_back(pii(b,x[now.fs]-x[pre.fs]));
      |                           ^