#include <bits/stdc++.h>
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define sorv(V) sort(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define upmax(a,b) (a)=max((a),(b))
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
vector<int> HLX;
int A[305], B[305];
int H, W, N, Ans;
void solve(int lx, int rx) {
unordered_set<int> testX;
vector<int> XV;
for(int i = 1, l, r; i <= N; i++) {
l = B[i]-lx; r = B[i]+rx;
if(l < 1) l = 1;
if(W < r) r = W;
XV.eb(l); XV.eb(r+1);
if(1 < l) testX.insert(l-1);
}
XV.eb(W+1);
testX.insert(W);
sorv(XV); univ(XV);
if(1 != XV[0]) return;
vector<vector<int>> EV(sz(XV));
for(int i = 1, l, r; i <= N; i++) {
l = B[i]-lx; r = B[i]+rx;
if(l < 1) l = 1;
if(W < r) r = W;
l = int(lower_bound(allv(XV), l) - XV.begin());
r = int(lower_bound(allv(XV), r+1) - XV.begin());
EV[l].eb(A[i]);
EV[r].eb(-A[i]);
}
int mxu = 0, mxd = 0, mxs = 0;
multiset<int> YV;
YV.insert(0); YV.insert(H+1);
for(int x = 0, xn = sz(XV); x+1 < xn; x++) {
for(int y : EV[x]) {
if(0 < y) YV.insert(y);
else YV.erase(YV.find(-y));
}
if(2 == sz(YV)) return;
if(testX.end() == testX.find(XV[x])) continue;
int prv = 0;
for(int y : YV) {
if(!prv) upmax(mxu, y-1);
else if(H+1 == y) upmax(mxd, y-prv-1);
else upmax(mxs, y-prv-1);
prv = y;
}
}
ll ret = ll(max(mxs, mxu+mxd)) + lx + rx;
if(ret < Ans) Ans = ret;
}
int main() {
ios::sync_with_stdio(false);
cin >> H >> W >> N;
for(int i = 1; i <= N; i++) cin >> A[i] >> B[i];
Ans = H+W;
HLX.eb(0);
for(int i = 1; i <= N; i++) HLX.eb(B[i]-1);
sorv(HLX); univ(HLX);
for(int lx : HLX) {
vector<int> XV;
XV.eb(W);
for(int i = 1, t; i <= N; i++) {
t = B[i]-lx-1;
if(0 < t) XV.eb(t);
}
sorv(XV); univ(XV);
}
Compilation message
sparklers.cpp: In function 'int main()':
sparklers.cpp:86:2: error: expected '}' at end of input
}
^