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

但是我还是WA,还要注意什么情况呢?

Posted by iscxy at 2005-02-07 20:36:54 on Problem 1002
In Reply To:Do you consider these cases? Posted by:iscxy at 2005-02-07 20:24:27
在考虑到这些情况下,在自己机器上都通过了,但提交就WA。

换了HASH表,只对重复的排序,结果WA。
我用空间换时间的方法,几乎把30000k内存都用上了,好处是自然有序,结果WA。
TLE也好啊,我会去优化。
#define N 10000000
unsigned short dupLow[N]={0};
unsigned char dupHigh[N]={0};
int main()
{
	int n,i,j,v;
	char c,str[80];
	int map[]={2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,7,8,8,8,9,9,9,9};
	cin>>n;
	for (i=0;i<n;i++){
		cin>>str;
		v=0;j=0;
		while(c=str[j++]){
			if (c=='-') continue;	//略过'-'
			if (c>='A' && c<='Z') //映射转换
				v = v*10 +map[c-'A'];
			else
				v = v*10 +c-'0';
		}
		if (dupLow[v]==0xffff)	dupHigh[v]++; //进位
		dupLow[v]++;
		
	}
	bool f=true;
	unsigned int dup;
	for (i=0;i<N;i++)
		dup=dupLow[i]+((unsigned int)dupHigh[i]<<16);
		if (dup>1) {
			cout<<setfill('0')<<setw(3)<<i/10000;
			cout<<'-';
			cout<<setw(4)<<i%10000<<' '<<dup<<endl;
			f=false;
		}
	if (f) cout<<"No duplicates."<<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