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 HaiShi_ at 2016-01-21 17:34:18 on Problem 3485
#include <cstdio>
#include <algorithm>
#include <cmath>
#define eps 1e-7
using namespace std;
const int maxn = 10000+10;

struct village {
  double o,l;
  bool operator < (const village& b) const {
    return l<b.l || fabs(l-b.l)<=eps && o > b.o;
  } 
}a[maxn];

int main()
{
	int L, D;
	double u, v, t;
	int n;
	while(scanf("%d%d%d",&L,&D,&n) != EOF) {
	  for(int i(0); i < n; i++) {
	    scanf("%lf%lf",&u,&v);
	    t = sqrt(D*D - v*v);
	    u = max(u-t,0.0); v = min(u+t,(double)L);
	    a[i].o = u, a[i].l = v;
	  }
	  sort(a,a+n);
	  int cnt(1); double pos = a[0].l;
	  for(int i(0); i < n; i++) {
		if(pos<a[i].o) {pos=a[i].l;cnt++;}
	  }
	  printf("%d\n",cnt);
	}
}

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