Submission #543516

#TimeUsernameProblemLanguageResultExecution timeMemory
543516brunnorezendesFountain Parks (IOI21_parks)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define s second #define f first using namespace std; typedef vector <int> vi; typedef pair<int, int> ii; typedef pair<ii, ii> iiii; typedef vector<ii> vii; typedef map <pair<int,int>, int > mpair; mpair mp, match1; vi u, v, a, b; vii match2; iiii find(int t, vi x, vi y){ ii c, d; iiii e; int i = u[t], j = v[t]; if(x[i]==x[j]){ c = {x[i]+1, (y[i]+y[j])/2}; d = {x[i]-1, (y[i]+y[j])/2}; e = {c, d}; return (e); } else{ c = {(x[i]+x[j])/2, y[i]+1}; d = {(x[i]+x[j])/2, y[i]-1}; e = {c, d}; return (e); } } int matching(int t, vi x, vi y){ iiii retur; ii op1, op2; retur = find(t, x, y); op1 = retur.f; op2 = retur.s; if(!match1[op1]){ match1[op1] = t+1; match2[t] = op1; return 1; } else if(!match1[op2]){ match1[op2] = t+1; match2[t] = op2; return 1; } else{ if((match1[op1] != t+1) && (match1[op2] != t+1)){ return 0; } if(match1[op2]==t+1) swap(op1, op2); if(matching(match1[op2]-1, x, y)){ match1[op2] = t+1; match2[t] = op2; return 1; } } } int maskx[4], masky[4]; int construct_roads(vi x, vi y){ maskx[1] = 2; maskx[3] = -2; masky[0] = 2; masky[2] = -2; int n = x.size(), i, f, j; match2 = vii(n, {-1, -1}); for(i=0;i<n;i++){ mp[{x[i], y[i]}] = i+1; } for(i=0;i<n;i++){ for(j=0;j<4;j++){ f = mp[{x[i]+maskx[j], y[i]+masky[j]}]; if(f>i+1){ f--; u.push_back(i); v.push_back(f); } } } for(i=0;i<u.size();i++){ if(!matching(i, x, y)) return 0; } for(i=0;i<u.size();i++){ a.push_back(match2[i].f); b.push_back(match2[i].s); } build(u, v, a, b); return 1; }

Compilation message (stderr)

parks.cpp: In function 'int construct_roads(vi, vi)':
parks.cpp:84:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   84 |  for(i=0;i<u.size();i++){
      |          ~^~~~~~~~~
parks.cpp:87:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   87 |  for(i=0;i<u.size();i++){
      |          ~^~~~~~~~~
parks.cpp:91:2: error: 'build' was not declared in this scope
   91 |  build(u, v, a, b);
      |  ^~~~~
parks.cpp: In function 'int matching(int, vi, vi)':
parks.cpp:62:1: warning: control reaches end of non-void function [-Wreturn-type]
   62 | }
      | ^