Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define PB push_back
- #define ZERO (1e-10)
- #define INF (1<<29)
- #define CL(A,I) (memset(A,I,sizeof(A)))
- #define DEB printf("DEB!\n");
- #define D(X) cout<<" "<<#X": "<<X<<endl;
- #define EQ(A,B) (A+ZERO>B&&A-ZERO<B)
- typedef long long ll;
- typedef long double ld;
- typedef pair<ll,ll> pll;
- typedef vector<int> vi;
- typedef pair<int,int> ii;
- typedef vector<ii> vii;
- #define IN(n) int n;scanf("%d",&n);
- #define FOR(i, m, n) for (int i(m); i < n; i++)
- #define REP(i, n) FOR(i, 0, n)
- #define F(n) REP(i, n)
- #define FF(n) REP(j, n)
- #define FT(m, n) FOR(k, m, n)
- #define aa first
- #define bb second
- void ga(int N,int *A){F(N)scanf("%d",A+i);}
- #define MX (100006)
- int C[MX],R[MX],W;
- int geco(int a){return C[a]=(a==C[a]?a:geco(C[a]));}
- bool con(int a,int b){
- if(geco(a)==geco(b))return 0;
- if(R[C[a]]>R[C[b]])C[C[b]]=C[a];
- else R[C[b]]+=R[C[a]]==R[C[b]],C[C[a]]=C[b];
- return --W,1;
- }
- #define CLR (iota(C,C+D,0),CL(R,0),W=D)
- int N,X[MX],Y[MX],Z[MX],x[MX],y[MX],z[MX],D,a,b;
- unordered_map<int,int> T;
- set<ii> S;
- int gw(int x,int y,int z){
- int H=x+y*1000+z*1000000;
- if(!T.count(H))T[H]=D++;
- return T[H];
- }
- bool ccl(bool p){
- T.clear(),D=0,S.clear();
- F(N){
- a=gw(X[i],Y[i],p*Z[i]),b=gw(x[i],y[i],p*z[i]);
- if(a^b)S.insert({min(a,b),max(a,b)});
- }
- CLR;
- for(auto&h:S)if(!con(h.aa,h.bb))return 0;
- return 1;
- }
- int main(void){
- while(~scanf("%d",&N)){
- F(N)scanf("%d%d%d%d%d%d",X+i,Y+i,Z+i,x+i,y+i,z+i);
- puts(!ccl(1)?"True closed chains":"No true closed chains");
- puts(!ccl(0)?"Floor closed chains":"No floor closed chains");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement