[GYM-101174K] [Problem K] Award ring + code Force + test Instructions

Source: Internet
Author: User
Tags bool

Reference https://vjudge.net/solution/7644516

Experience: Here's the u>=v limit, and then there is the map map for the edge ... For this heavy-edge situation, you can use map as such. Note that there are errors when using this point with the map. The ring should be more concise FST, and FF

However the following code is wrong, do not want to see

struct point{int x, y, Z; Point (int x=0,int y=0,int z=0): X (x), Y (y) {}//point (int x,int y,int z): X (0), y (0), Z (0) {} bool friend operator< ( Point A,point b) {return a.x<b.x| | (A.X==B.X&AMP;&AMP;A.Y&LT;B.Y) | |
    (A.X==B.X&AMP;&AMP;A.Y==B.Y&AMP;&AMP;A.Z&LT;B.Z);
}
};
    struct point2{int x, y; Point2 (int x=0,int y=0): X (x), Y (y) {}//point2 (int x,int y): X (0), y (0) {} bool friend operator < (Point2 A,point2 b) {return a.x<b.x| |
    (A.X==B.X&AMP;&AMP;A.Y&LT;B.Y);
}
};
int n;
map<point,int>mp1;
Map<point2,int >mp2;
map<pii,int>f1,f2;
int cnt1,cnt2;
int OK;
    int id1 (int x,int y,int z) {if (Mp1.count (x, Y, z) ==0) {mp1[point (x, Y, z)]=++cnt1;
} return Mp1[point (x, Y, z)];
    } int id2 (int x,int y) {if (Mp2.count (Point2 (x, y)) ==0) {Mp2[point2 (x, y)]=++cnt2;
} return Mp2[point2 (x, y)];
} int vis[n];
int fst[n<<1],nxt[n<<2],ff[n<<1],vv[n<<2],e; void dfs1 (int u,int p) {if (Vis[u])
    {Ok=1;return;
    } vis[u]=1;
        for (int i=fst[u];~i&&!ok;i=nxt[i]) {int v=vv[i];
        if (v==p) continue;
    DFS1 (V,u);
    }} void dfs2 (int u,int p) {if (Vis[u]) {Ok=1;return;
    } vis[u]=1;
        for (int i =ff[u];~i&&!ok;i=nxt[i]) {int v=vv[i];
        if (v==p) continue;
    DFS2 (V,u);
    }} void Init () {mem (fst,-1);
MEM (ff,-1); e=0; } void Add (int u,int v) {vv[e]=v;nxt[e]=fst[u];fst[u]=e++;} void _add (int u,int v) {vv[e]=v;nxt[e]=ff[u];ff[u]=e+
+;
    } int main () {ree//cin>>n;
    SF ("%d", &n);
    Init ();
    cnt1=0,cnt2=0;
        Rep (i,1,n) {int x,y,z,xx,yy,zz;
        SF ("%d%d%d%d%d%d", &x,&y,&z,&xx,&yy,&zz);
        int U=id1 (x, Y, z), V=ID1 (XX,YY,ZZ);
        if (u<v) swap (U,V);
        if (u==v) continue;
            if (F1.count (MP (u,v)) ==0) {f1[mp (u,v)]=1;
        Add (u,v); add (V,u);
       } u=id2 (x, y); V=id2 (XX,YY); if (u<v) swap (U,V);
        if (u==v) continue;
            if (F2.count (MP (u,v)) ==0) {f2[mp (u,v)]=1;
        _add (u,v); _add (V,u);
        }}//cout<<cnt1<< ' <<cnt2<<endl;
    ok=0;
    MEM (vis,0);
            for (int i=1;i<=cnt1;++i) {if (!vis[i]) {DFS1 (i,i);
        if (OK) break;
    }} if (OK) puts ("True closed chains");
    Else puts ("No true closed Chains");
    ok=0;
    MEM (vis,0);
            for (int i=1;i<=cnt2;++i) {if (!vis[i]) {DFS2 (i,i);
        if (OK) break;
    }} if (OK) puts ("Floor closed chains");
Else puts ("No floor closed chains");
 }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.