Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

floyd。。。求测试数据,为何不过

Posted by celia01 at 2011-07-19 10:58:07 on Problem 3660
#include<iostream>
#include<cstdio>
using namespace std;
#define maxn 32700
int main(){
    int a[105][105]={0};
    int m, n, i, j, k;
    cin>>n>>m;
    int x=0, y=0, s=0;
    while(m--){
               cin>>i>>j;
               a[i][j] = 1;
    }
    for (i=1;i<=n;i++){
        for(k=1;k<=n;k++){
             if (a[i][k]){
                  for(j=1;j<=n;j++){
                       if (a[k][j]){
                                    a[i][j]=1;
                       }
                  }
             }
        }
    }
    for (k=1;k<=n;k++){
        x=0;y=0;
        for (i=1;i<=n;i++){
            if (a[i][k]){
                 x++;
                 //cout<<"x:"<<x<<endl;
            }
        }
        for (j=1;j<=n;j++){
            if (a[k][j]){
                 y++;
                 //cout<<"y:"<<y<<endl;
            }
        }
        if (x+y==n-1)
            s++;
    }
    cout<<s<<endl;
    system("pause");
    return 0;
}    
                       
    

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator