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");
        }
    }

  • 相关阅读:
    Intent.ACTION_TIME_TICK 广播
    Android ContentObserver
    android:duplicateParentState属性解释
    Android CursorAdapter
    android AndroidManifest.xml 多个android.intent.action.MAIN (
    PreferenceActivity详解
    WORD和WPS中英文混合的内容间距离很大怎么办?
    Android 屏幕适配
    OC第四课
    PL/SQL联系oracle成功可以sql解决的办法是检查表的名称无法显示
  • 原文地址:https://www.cnblogs.com/dchipnau/p/4985935.html
Copyright © 2011-2022 走看看