zoukankan      html  css  js  c++  java
  • [SCOI2010]连续攻击游戏

     1 #include<cstdio>
     2 #include<cctype>
     3 #include<algorithm>
     4 inline int getint() {
     5     register char ch;
     6     while(!isdigit(ch=getchar()));
     7     register int x=ch^'0';
     8     while(isdigit(ch=getchar())) x=(((x<<2)+x)<<1)+(ch^'0');
     9     return x;
    10 }
    11 const int M=10001;
    12 int anc[M];
    13 bool vis[M];
    14 int find(const int &x) {
    15     return x==anc[x]?x:anc[x]=find(anc[x]);
    16 }
    17 int main() {
    18     for(register int i=0;i<M;i++) anc[i]=i;
    19     for(register int n=getint();n;n--) {
    20         int x=find(getint()-1),y=find(getint()-1);
    21         if(x==y) {
    22             vis[x]=true;
    23         } else {
    24             if(x>y) std::swap(x,y);
    25             vis[vis[x]?y:x]=true;
    26             anc[x]=y;
    27         }
    28     }
    29     for(register int i=0;i<M;i++) {
    30         if(!vis[i]) {
    31             printf("%d
    ",i);
    32             return 0;
    33         }
    34     }
    35 }
  • 相关阅读:
    页面的加载过程
    free 命令
    linux chmod命令(转)
    less 命令(转)
    cat 命令(转)
    cp 命令(转)
    mv命令(转)
    rm 命令(转)
    mkdir命令
    Docker网络基础
  • 原文地址:https://www.cnblogs.com/skylee03/p/7978930.html
Copyright © 2011-2022 走看看