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

Re:为什么会WA呢?高手指点啊,给个测试数据吧

Posted by kenhuang at 2008-05-07 23:38:02 on Problem 2419
In Reply To:为什么会WA呢?高手指点啊,给个测试数据吧 Posted by:00 at 2005-06-30 18:38:52
> #include<iostream.h>
> void main()
> {
> 	int P,T,a,b,i,j;
> 	cin>>P>>T;
> 	int pt[101][101];
> 	while(cin>>a>>b)
> 		pt[a-1][b-1]=1;
> 	int r=P;
> 	for(i=0;i<P;i++)
> 	{
> 		for(j=i+1;j<P;j++)
> 		{
> 			for(int k=0;k<P;k++)
> 			{
> 				if(pt[i][k]!=pt[j][k])
> 					break;
> 			}
> 			if(k==P)
> 				r--;
> 		}
> 	}
> 	cout<<r<<endl;
> }

和你的思路几乎一样,但是你的好像最后一个for循环有问题哦,结束循环的条件是k<T吧!

而且如果是多于两个人的看法一样的话就有错误了,应该在
if(k==P) r--;之间加上i++;哦 !

我的代码是

#include <iostream>
using namespace std;
int main()
{
    int p,t,m,n,difp,a[103][103]={};
    cin>>p>>t;
    difp=p;
    while(cin>>m>>n){
        a[m-1][n-1]=1;                   
        }
    for(int i=0;i<p;i++)
      for(int j=i+1,k;j<p;j++)
      {
         for(k=0;k<t;k++)
         {
           if(a[i][k]!=a[j][k])  break;  
           else continue;
            }  
           if(k==t)   {i++;difp--;}       //如果是三个人都有相同的想法i必须++       
         }    
    cout<<difp<<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