#include #include"testlib.h" using namespace std; using ll = long long; const ll Nmin = 1, Nmax = 200'000; const ll Mmin = 1, Mmax = 200'000; const ll ABCmin = 0, ABCmax = 100; const ll XYZmin = -100, XYZmax = 100; const ll linf = 1e18; template bool chmax(T &a, const T &b){ if (a >= b) return false; a = b; return true; } template bool chmin(T &a, const T &b){ if (a <= b) return false; a = b; return true; } int main(){ registerValidation(); ll n = inf.readLong(Nmin,Nmax); inf.readSpace(); ll m = inf.readLong(Mmin,Mmax); inf.readEoln(); set> abc; ll al = linf, ar = -linf; ll bl = linf, br = -linf; ll cl = linf, cr = -linf; for (ll i = 0; i < n; i++){ ll a = inf.readLong(ABCmin,ABCmax); inf.readSpace(); ll b = inf.readLong(ABCmin,ABCmax); inf.readSpace(); ll c = inf.readLong(ABCmin,ABCmax); inf.readEoln(); abc.insert(make_tuple(a,b,c)); chmax(ar,a); chmin(al,a); chmax(br,b); chmin(bl,b); chmax(cr,c); chmin(cl,c); } ensuref((ll)(abc.size()) == n, "(A,B,C) must be distinct"); set> xyz; ll xl = linf, xr = -linf; ll yl = linf, yr = -linf; ll zl = linf, zr = -linf; for (ll i = 0; i < m; i++){ ll x = inf.readLong(XYZmin,XYZmax); inf.readSpace(); ll y = inf.readLong(XYZmin,XYZmax); inf.readSpace(); ll z = inf.readLong(XYZmin,XYZmax); inf.readEoln(); xyz.insert(make_tuple(x,y,z)); chmax(xr,x); chmin(xl,x); chmax(yr,y); chmin(yl,y); chmax(zr,z); chmin(zl,z); } ensuref((ll)(xyz.size()) == m, "(X,Y,Z) must be discinct"); // for (auto [a, b, c] : abc) for (auto [x, y, z] : xyz){ // ensure(ABCmin <= a+x && a+x <= ABCmax); // ensure(ABCmin <= b+y && b+y <= ABCmax); // ensure(ABCmin <= c+z && c+z <= ABCmax); // } ensure(ABCmin <= al+xl); ensure(ar+xr <= ABCmax); ensure(ABCmin <= bl+yl); ensure(br+yr <= ABCmax); ensure(ABCmin <= cl+zl); ensure(cr+zr <= ABCmax); inf.readEof(); }