#include #include #include #include #include #include #include #include #include #define mp make_pair using namespace std; typedef long long ll; typedef pair pii; struct point { ll x, y, z; void read () { int _x, _y, _z; scanf("%d%d%d", &_x, &_y, &_z); x=_x, y=_y, z=_z; } }; bool operator < (const point& a, const point& b) { if (a.x!=b.x) return a.x E[3*MAXF]; bool u[MAXF]; void dfs (int g) { int j, v1, v2, i, ng; u[g]=1; for (i=0; i<3; i++) { v1=P[g][i]; v2=P[g][(i+1)%3]; /*BOXNEXT*/ ng=lower_bound(E,E+ee,mp(mp(min(v1,v2),max(v1,v2)),g))-E; /*BOXNEXT*/ assert(E[ng]==mp(mp(min(v1,v2),max(v1,v2)),g)); ng=E[ng^1].second; if (u[ng]) continue; for (j=0; j<3; j++) if (P[ng][j]==v1 && P[ng][(j+1)%3]==v2) { swap(P[ng][j],P[ng][(j+1)%3]); break; } dfs(ng); } } int main() { int i, l, r, j, cnt, x, y; ll ans=0; freopen ("volume.in", "r", stdin); freopen ("volume.out", "w", stdout); scanf("%d", &n); for (i=0; i1) (A[i][j]