QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#53900#4838. Rotate Sum 2zhoukangyang#WA 2ms3776kbC++111.3kb2022-10-06 11:42:572022-10-06 11:42:58

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-06 11:42:58]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3776kb
  • [2022-10-06 11:42:57]
  • 提交

answer

#include<bits/stdc++.h>
#define L(i, j, k) for(int i = (j); i <= (k); ++i)
#define R(i, j, k) for(int i = (j); i >= (k); --i)
#define ll long long
#define sz(a) ((int) (a).size())
#define vi vector < int > 
#define me(a, x) memset(a, x, sizeof(a))
#define ull unsigned long long
#define ld __float128
#define double long double 
using namespace std;
const int N = 1e6 + 7;
double x[N], y[N];
int n;
const double pi = acos(-1);
int main() {
	ios :: sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> n;
	double s = 0;
	L(i, 1, n) {
		cin >> x[i] >> y[i];
	}
	L(i, 1, n) {
		s += x[i] * y[i % n + 1] - x[i % n + 1] * y[i];
	}
	s /= 2;
	double ns = 0, tmp = 0, all = 0, qx = 0, qy = 0;
	L(i, 1, n) all += x[i] * x[i], qx += x[i], qy += y[i];
	L(i, 1, n) {
		int lst = (i + n - 2) % n + 1, nxt = i % n + 1;
		double qc = atan2(y[lst] - y[i], x[lst] - x[i]) - atan2(y[nxt] - y[i], x[nxt] - x[i]);
		if(qc < 0) qc += pi * 2;
		double w = pi - qc;
		assert(fabs(w) >= 0);
		tmp += w;
		
		double qwq = 0;
		qwq -= 2 * qx * x[i];
		qwq -= 2 * qy * y[i];
		qwq += all * n;
		qwq += (x[i] * x[i] + y[i] * y[i]) * n;
		ns += qwq * w;
	}
	cout.precision(12), cout << fixed;
	cout << ns / n / 2 + s << '\n';
	return 0;
}
/*
3
1 1
1 -1
-1 2
*/

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 3776kb

input:

3
1 -1
1 1
-1 2

output:

18.763234503174

result:

ok found '18.76323', expected '18.76323', error '0.00000'

Test #2:

score: -100
Wrong Answer
time: 2ms
memory: 3776kb

input:

4
-1000000000 1000000000
-1000000000 -1000000000
1000000000 -1000000000
1000000000 1000000000

output:

22849555921538758696.000000000000

result:

wrong answer 1st numbers differ - expected: '16566370614359173120.00000', found: '22849555921538760704.00000', error = '0.37927'