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

这么做就算答案对了也要TLE....

Posted by wpolly at 2007-04-01 21:20:17 on Problem 3213
In Reply To:Problem D:PM3 总是WA,请那位帮忙看哈,附上代码和注释的,万分的感谢!!!!!!!! Posted by:20054738 at 2007-04-01 20:57:27
> #include<iostream.h>
> #include<stdio.h>
> 
> #define max 1005
> int ma[max][max],mb[max][max],mc[max][max],mec[max][max];
> int main()
> {
> 	int n,p,m;
> 	int i,j,k;
> 	//int ma[max][max],mb[max][max],mc[max][max];//,mec[1001][1001];
> 	int temp;
> 	cin>>n>>p>>m;
> 	for(i=0;i<n;i++)
> 	{
> 		for(j=0;j<p;j++)
> 			//cin>>ma[i][j];
> 			scanf("%d",&ma[i][j]);
> 	}
> 	for(i=0;i<p;i++)
> 	{
> 		for(j=0;j<m;j++)
> 			//cin>>mb[i][j];
> 			scanf("%d",&mb[i][j]);
> 	}
> 	for(i=0;i<n;i++)
> 	{
> 		for(j=0;j<m;j++)
> 			//	cin>>mc[i][j];
> 			scanf("%d",&mc[i][j]);
> 	}
> 	//以下12行是矩阵的乘法
> 	for(i=0;i<n;i++)
> 	{	
> 		for(k=0;k<m;k++)
> 		{
> 			temp=0;
> 			for(j=0;j<p;j++)
> 			{
> 				temp=temp+ma[i][j]*mb[j][k];
> 			}
> 			mec[i][k]=temp;
> 		}
> 	}
> 	//下面几句是检测有没错误元素
> 	for(i=0;i<n;i++)
> 	{
> 		for(j=0;j<m;j++)
> 		{
> 			if(mec[i][j]!=mc[i][j])
> 			{
> 				cout<<"No"<<endl;
> 				cout<<(i+1)<<" "<<(j+1)<<endl;
> 				cout<<mec[i][j]<<endl;
> 				return 0;
> 			}
> 		}
> 	}
> 	/*
> 	for(i=0;i<n;i++)
> 	{
> 	for(j=0;j<m;j++)
> 	cout<<mec[i][j]<<" ";
> 	cout<<endl;
> 	}
> 	*/
> 	cout<<"Yes"<<endl;
> 	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