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

这个是贪心构造!程序自己改!

Posted by frkstyc at 2005-05-10 15:53:15 on Problem 1659
In Reply To:能不能给出一些测试数据给我!或者帮改程序! Posted by:wanpi0user at 2005-05-10 15:34:44
> 我的程序通过了测试数据,可是是WA。请问管理员可否提供更多的测试数据以供测试,或者帮我看看程序。
> 我的程序如下:
> //457790 wanpi0user 1659 Wrong Answer     C++ 0.86K 2005-05-10 15:29:52 
> #include <iostream>
> #include <memory.h>
> #include<algorithm>
> using namespace std;
> int n, t, x[20], map[20][20];
> int main()
> {
> 	int i,j,k,bCase,Odd;
> 	bool con;
> 	cin>>t;
> 	while(t--){
> 		memset(x, 0, sizeof(x));
> 		memset(map, 0, sizeof(map));
> 		bCase = 0;Odd=0;con=true;
> 		cin>>n;
> 		for (j = 0; j < n; j++) {
> 			cin>>x[j];
> 			if(x[j]%2) Odd++;
> 			if (x[j]) bCase++;
> 		}
> 		if(Odd%2||bCase==0) con=false;
> 		else{
> 			j=0;
> 			while(j<n){
> 				if(x[j]){
> 					for(i=j+1;i<n;i++){
> 						if(x[i]&&x[j]){
> 							map[i][j]=map[j][i]=1;x[j]--;x[i]--;
> 						}
> 					}
> 				}
> 				j++;
> 			}
> 			for(i=0;i<bCase;i++) if(x[i]) con=false;
> 		}
> 		if (con){
> 			cout<<"YES"<<endl;
> 			for (j = 0; j < n; j++) {
> 				for (k = 0; k < n; k++)
> 					cout<<map[j][k]<<' ';
> 				cout<<endl;
> 			}
> 		}
> 		else{
> 			cout<<"NO"<<endl;
> 		}
> 		if(t) cout<<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