zoukankan      html  css  js  c++  java
  • joj 2651

    水题,我竟然把Yes和No写成了YES和NO。。。。。

    #include<iostream>
    #include<stdio.h>
    using namespace std;
    int frid[105][105];
    int cloth[105];
    int n;
    int r_right;
    void dfs(int m,int c)
    {
         //cout<<m<<endl;
        if(r_right==0)
           return;
        int j;
        for(j=0;j<n;j++)
        {
            if(frid[m][j])
            {
                if(cloth[j]==-1)
                {
                    cloth[j]=1-cloth[m];
                    dfs(j,cloth[j]);
                }
                else
                {
                    if(cloth[j]!=1-cloth[m])
                    {
                      r_right=0;
                      return;
                    }
                }
            }
        }
    }
    int main()
    {
        while(scanf("%d",&n),n)
        {
            int i,j;
            r_right=1;
            memset(cloth,-1,sizeof(cloth));
            for(i=0;i<n;i++)
               for(j=0;j<n;j++)
                  scanf("%d",&frid[i][j]);
            for(i=0;i<n&&r_right;i++)
            {
                if(cloth[i]==-1)
                {
                     cloth[i]=0;
                     dfs(i,0);
                }
            }
            if(r_right)
                 printf("Yes\n");
            else
                 printf("No\n");
        }
    }

  • 相关阅读:
    docker articles&videos
    Docker Resources
    IL-rewriting profiler
    memory dump and CLR Inside Out
    tcp/ip basics
    What Every CLR Developer Must Know Before Writing Code
    CLR profiler
    Debug CLR and mscorlib
    JIT Compiler
    calling into the CLR from managed code via QCall and FCall methods
  • 原文地址:https://www.cnblogs.com/dchipnau/p/4985935.html
Copyright © 2011-2022 走看看