Submission #598619

#TimeUsernameProblemLanguageResultExecution timeMemory
598619definitelynotmeeFountain Parks (IOI21_parks)C++17
Compilation error
0 ms0 KiB
#include "parks.h" #include<bits/stdc++.h> using namespace std; #define ff first #define ss second #define all(x) x.begin(), x.end() using ll = long long; using pii = pair<int,int>; using pll = pair<ll,ll>; template<typename t> using matrix = vector<vector<t>>; int construct_roads(std::vector<int> x, std::vector<int> y) { if (x.size() == 1) { build({}, {}, {}, {}); return 1; } int n = x.size(); std::vector<int> u, v, a, b; int dx[]{1,0,-1,0}; int dy[]{0,1,0,-1}; vector<int> pai(n); int comp = n; iota(all(pai),0); auto find =[&](int id, auto f){ if(pai[id] = id) return id; return pai[id] = f(pai[id],f); }; auto onion =[&](int a, int b){ pa = find(a,find); pb = find(b,find); if(pa != pb){ comp--; u.push_back(a); v.push_back(b); } }; map<pii,int> fount; for(int i = 0; i < n; i++) fount[{x[i],y[i]}] = i; for(int i = 0; i < n; i++){ for(int j = 0; j < 4; j++){ int xi = x[i] + dx[j]*2, yi = y[i]+dy[j]*2; if(fount.count({xi,yi})) onion(i,fount[{xi,yi}]); } } if(comp > 1) return 0; set<pii> bench; for(int i = 0; i < n-1; i++){ int cx = (x[u[i]]+x[v[i]])>>1, cy = (y[u[i]]+y[v[i]])>>1; bool ok = 0; for(int j = 0; j < 4; j++){ int xi = x[i] + dx[j], yi = y[i]+dy[j]; if((xi&1)||(yi&1)) continue; if(!bench.count({xi,yi})){ a.push_back(xi); b.push_back(yi); ok = 1; break; } } if(!ok) return 0; } return 1; }

Compilation message (stderr)

parks.cpp: In lambda function:
parks.cpp:35:9: error: 'pa' was not declared in this scope; did you mean 'pai'?
   35 |         pa = find(a,find);
      |         ^~
      |         pai
parks.cpp: In instantiation of 'construct_roads(std::vector<int>, std::vector<int>)::<lambda(int, auto:23)> [with auto:23 = construct_roads(std::vector<int>, std::vector<int>)::<lambda(int, auto:23)>]':
parks.cpp:35:25:   required from here
parks.cpp:30:20: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   30 |         if(pai[id] = id)
parks.cpp:36:9: error: 'pb' was not declared in this scope; did you mean 'b'?
   36 |         pb = find(b,find);
      |         ^~
      |         b
parks.cpp: In function 'int construct_roads(std::vector<int>, std::vector<int>)':
parks.cpp:61:13: warning: unused variable 'cx' [-Wunused-variable]
   61 |         int cx = (x[u[i]]+x[v[i]])>>1, cy = (y[u[i]]+y[v[i]])>>1;
      |             ^~
parks.cpp:61:40: warning: unused variable 'cy' [-Wunused-variable]
   61 |         int cx = (x[u[i]]+x[v[i]])>>1, cy = (y[u[i]]+y[v[i]])>>1;
      |                                        ^~