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

加了memset就ac, 我用vc6.0,本地不要memset也默认为0,是不是不够标准?

Posted by bmexue at 2006-11-19 13:50:34 on Problem 3099
In Reply To:有什么要注意的,为什么我老是错? 程序有注解 Posted by:bmexue at 2006-11-19 13:39:26
> #include <iostream>
> #include <cmath>
> #include <vector>
> using namespace std;
> struct Planet
> {
> 	int id,x,y,z;
> };
> int N;
> Planet d[1001];
> int cnt[1001][1001]; //&Ecirc;&yacute;&frac34;&Yacute;&frac12;á&sup1;&sup1;&Ograve;&ordf;&cedil;&Atilde;&Ograve;&raquo;&Iuml;&Acirc;
> 
> 
> int dis(int i, int j)
> {
> 	return pow(d[i].x-d[j].x,2) + pow(d[i].y-d[j].y,2)+pow(d[i].z-d[j].z,2);
> }
> 
> void work()
> {
>     if(N==1){
> 		cout<<d[1].id<<endl; 
> 		return;
> 	}
> 	if(N==2){
> 		if(d[1].id<d[2].id)
> 		   cout<<d[1].id<<" "<<d[2].id<<endl; 
> 		else
>            cout<<d[2].id<<" "<<d[1].id<<endl;
> 		return;
> 	}
>     for(int j=1;j<=N;j++){ //init;
> 		cnt[j][j] = 0;
> 	}
> 	int i=2,p,tmp_dis,tmp_id;
> 	int max_num[1001]; int tmp;
> 
> 	while(i<=N){   //×&ouml;&sup3;&ouml;&Aacute;&not;&frac12;&Oacute;&Ccedil;é&iquest;&ouml;
> 
>         tmp_dis = 9000000; p=1;
> 		while(p<i){  //&Ntilde;°&Otilde;&Ograve;×&icirc;&frac12;ü&micro;&Auml;  save to tmp_id
> 		    tmp = dis(i,p);
> 			if( tmp < tmp_dis){  //&Otilde;&Ograve;
> 				tmp_dis =  tmp ; tmp_id = p;  //&Otilde;&acirc;&Agrave;&iuml;&sup2;&raquo;&Ecirc;&Ccedil;&Otilde;&aelig;&Otilde;&yacute;&micro;&Auml;id   &para;&oslash;&Ecirc;&Ccedil;&Ecirc;&yacute;×é&micro;&Auml;&Iuml;&Acirc;±ê
> 			}
> 			p++;
> 		}
> 
> 		cnt[i][tmp_id] = 1; cnt[tmp_id][i] = 1;  //&sup2;é&iquest;&acute;p&micro;&frac12;1.&iexcl;&pound;&iexcl;&pound;&iexcl;&pound;i-1&micro;&Auml;&frac34;à&Agrave;&euml;
> 		int k=1;
> 		while(k<i){
> 			if(k!=tmp_id){
>                cnt[i][k] = cnt[tmp_id][k]+1;  //p==k?
> 			   cnt[k][i] = cnt[i][k];
> 			}
> 			k++;
> 		}
>         
> 		i++;
> 	}
>     
>     for(i=1;i<=N;i++)  //&cedil;&oslash;&Atilde;&iquest;&Ograve;&raquo;&cedil;&ouml;&frac12;&Uacute;&micro;&atilde;&Ntilde;°&Otilde;&Ograve;×&icirc;&Ocirc;&para;&micro;&Auml;count
> 	{
> 		for(j=1;j<=N;j++)
> 		{
> 			if(cnt[i][j] > max_num[i])
> 				max_num[i] = cnt[i][j];
> 		}
> 	}
>    
> 
> 
> 	int rst1, rst2,tmp_here1=1500;
> 	i=1;
> 	while(i<=N){
> 		if(max_num[i]<tmp_here1)
> 		{
>             rst1 = i; tmp_here1 = max_num[i];
> 		}
>     	i++;
> 	}
> 	i=1; int tmp_here2=1500;
> 	while(i<=N)
> 	{
> 		if(i==rst1){
>             i++;
> 			continue;
> 		}
> 	    if(max_num[i]<tmp_here2)
> 		{
>             rst2 = i; tmp_here2 = max_num[i];
> 		}
>     	i++;
>         
> 	}
> 	if(tmp_here1!=tmp_here2)  //&Ntilde;°&Otilde;&Ograve;&micro;&Auml;×&icirc;&acute;ó&frac34;à&Agrave;&euml;&sup2;&raquo;&Ograve;&raquo;&Ntilde;ù
> 		cout<<d[rst1].id<<endl;
> 	else //the same
> 	{
> 		if(d[rst1].id<d[rst2].id)
> 		   cout<<d[rst1].id<<" "<<d[rst2].id<<endl;
> 		else
>             cout<<d[rst2].id<<" "<<d[rst1].id<<endl;
> 	}
> }
> int main()
> {
>   //  freopen("C:\\ACMData.txt","r",stdin);
> 	int p;
> 	while(true){
> 		scanf("%d", &N);
> 		if(N==0) return 0;
> 		p=1;
> 		while(p<=N){
> 			scanf("%d%d%d%d",&d[p].id, &d[p].x,&d[p].y,&d[p].z);
> 			p++;
> 		}
>         work();
> 	}
> 	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