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:为什么我老是RE啊!!!

Posted by trueshlqsh at 2007-10-21 17:11:25 on Problem 3424
In Reply To:为什么我老是RE啊!!! Posted by:trueshlqsh at 2007-10-21 17:10:28
> 有什么诡异的数据???我自己出了N组,都没有问题,极端的都跑过的啊。。。
> 为什么RE掉了!~~~哪位好心人帮帮我,谢谢拉~~~~~~~~~
#include <iostream>
using namespace std;

long n,north,south,east,west;
long data[201][3];
long tot;
long ans[1000000][101];
string last[1000000];

long get_point(long x,long y,long mx,long my)
{
	long nowx,nowy;
	nowx=x+mx;
	nowy=y+my;
	if (0<nowx&&nowx<=100&&200<nowy&&nowy<=300) return 1;
	if (100<nowx&&nowx<=200&&200<nowy&&nowy<=300) return 2;
	if (200<nowx&&nowx<=300&&200<nowy&&nowy<=300) return 3;
	if (0<nowx&&nowx<=100&&100<nowy&&nowy<=200) return 4;
	if (100<nowx&&nowx<=200&&100<nowy&&nowy<=200) return 5;
	if (200<nowx&&nowx<=300&&100<nowy&&nowy<=200) return 6;
	if (0<nowx&&nowx<=100&&0<nowy&&nowy<=100) return 7;
	if (100<nowx&&nowx<=200&&0<nowy&&nowy<=100) return 8;
	if (200<nowx&&nowx<=300&&0<nowy&&nowy<=100) return 9;
	return 0;
}

void check_ans()
{
	long i,j;
	bool pd;
	
	for (i=1;i<=tot-1;i++)
	{
		pd=true;
		for (j=1;j<=n;j++)
		if (ans[i][j]!=ans[tot][j]) {pd=false; break;}
		if (pd==true) {tot--;break;}
	} 
}

void get_ans()
{
	long point[101][3];
	long now[101];
	long i,j,k,p,x,y;
	
	for (i=2;i<=n;i++)
	{
		point[i][1]=data[i][1]-data[i-1][1];
		point[i][2]=data[i][2]-data[i-1][2];
	}
	for (i=1;i<=299;i++)
	  for (j=1;j<=299;j++)
	  {
			now[1]=get_point(0,0,i,j);
			x=i;y=j;k=2;
			while (k<=n)
			{
				if (k>n) break;
				now[k]=get_point(x,y,point[k][1],point[k][2]);
				if (now[k]==0) break;
				x=x+point[k][1];
				y=y+point[k][2];
				k++;
			}
			if (k>n) {
				       tot++;
				       for (p=1;p<=n;p++) ans[tot][p]=now[p];
				       check_ans();
				     }
	  }
}

void change_ans()
{
	long i,j;
	char ch;
	for (i=1;i<=tot;i++)
	  for (j=1;j<=n;j++)
	  {
			ch=ans[i][j]+48;
			last[i]=last[i]+ch;
	  }
}

void quick_sort(int l,int r)
{
   long i,j;
   string temp;
   i=l;j=r;
   temp=last[(i+j)/2];last[(i+j)/2]=last[i];last[i]=temp;
   while (i!=j)
   {
      while (temp<last[j]&&i!=j) j--;
      if (i!=j) 
      {
	     last[i]=last[j];
         i++;
   	  }
      while (temp>last[i]&&i!=j) i++;
      if (i!=j)
      {
	     last[j]=last[i];
         j--;
      }
   }
   last[i]=temp;
   if (i-1>l) quick_sort(l,i-1);
   if (i+1<r) quick_sort(i+1,r);
}

int main()
{
    long i,j;
    
	while (cin>>n)
	{
	for (i=1;i<=n;i++) cin>>data[i][1]>>data[i][2];
	west=data[1][1];east=data[1][1];
	north=data[1][2];south=data[1][2];
	for (i=2;i<=n;i++)
	{
		if (data[i][1]>east) east=data[i][1];
		if (data[i][1]<west) west=data[i][1];
		if (data[i][2]>north) north=data[i][2];
		if (data[i][2]<south) south=data[i][2];
	}	
	//main;
	tot=0;
	if (east-west>300||north-south>300) cout<<"NONE"<<endl;
	                               else {
										   get_ans(); 
										   change_ans();
										   quick_sort(1,tot);
									     }
	//print;
	for (i=1;i<=tot;i++) cout<<last[i]<<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