結果

問題 No.1385 Simple Geometry 2
ユーザー 沙耶花沙耶花
提出日時 2021-02-07 23:00:19
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,594 bytes
コンパイル時間 2,617 ms
コンパイル使用メモリ 199,936 KB
実行使用メモリ 11,584 KB
最終ジャッジ日時 2023-09-18 00:29:06
合計ジャッジ時間 13,566 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 4 ms
4,380 KB
testcase_04 AC 4 ms
4,380 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 4 ms
4,380 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 343 ms
4,376 KB
testcase_09 AC 352 ms
4,380 KB
testcase_10 AC 354 ms
4,380 KB
testcase_11 AC 347 ms
4,376 KB
testcase_12 AC 352 ms
4,380 KB
testcase_13 TLE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 TLE -
testcase_33 RE -
testcase_34 TLE -
testcase_35 RE -
testcase_36 TLE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 TLE -
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
testcase_45 RE -
testcase_46 TLE -
testcase_47 RE -
testcase_48 RE -
testcase_49 TLE -
testcase_50 RE -
testcase_51 RE -
testcase_52 RE -
testcase_53 RE -
testcase_54 TLE -
testcase_55 RE -
testcase_56 TLE -
testcase_57 RE -
testcase_58 RE -
testcase_59 RE -
testcase_60 RE -
testcase_61 RE -
testcase_62 RE -
testcase_63 RE -
testcase_64 RE -
testcase_65 RE -
testcase_66 RE -
testcase_67 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001


double theta[5001],r[5001];
int main(){
	
	int N;
	cin>>N;
	
	long long L;
	cin>>L;
	
	double PI = acos(-1.0);
	
	vector<double> x(N),y(N);
	rep(i,N){
		long long T;
		cin>>T;
		
		x[i] = cos(PI * 2.0 / L * T);
		y[i] = sin(PI * 2.0 / L * T);
	}
	
	double ans = 0.0;
	
	rep(i,N){
		double temp = 0.0;
/*
		rep(j,N){
			if(j==0)continue;
			jj++;
			if(jj>=N)jj = 0;
			
			r[j-1] = hypot(x[i]-x[jj],y[i]-y[jj]);
			theta[j-1] = atan2(y[jj]-y[i],x[jj]-x[i]);
		}
		*/
		
		int pos = i+1;
		if(pos==N)pos = 0;
		double sp = 0.0,cp = 0.0,sm = 0.0,cm = 0.0;
		int cntp = 0,cntm = 0;
		int jj = i;
		rep(j,N-1){
			jj++;
			if(jj>=N)jj = 0;
			while(pos!=jj){
				if(sin(theta[jj]-theta[pos])<=0.0){
					cntp--;
					cntm++;
					sp -= y[pos]-y[i];//sin(theta[pos])*r[pos];
					cp -= x[pos]-x[i];//cos(theta[pos])*r[pos];
					sm += y[pos]-y[i];//sin(theta[pos])*r[pos];
					cm += x[pos]-x[i];//cos(theta[pos])*r[pos];
					
					pos++;
					if(pos==N)pos = 0;
				}
				else break;
			}
			double ss = y[jj]-y[i];//
			double cc = x[jj]-x[i];//r[j] * sin(theta[j]),cc = r[j] * cos(theta[j]);
			double ttt = 0.0;
			if(j!=0){
				ttt += ss * cp;
				ttt -= cc * sp;
				ttt -= ss * cm;
				ttt += cc * sm;
				//ttt *= cntp+cntm;
			}
			//cout<<ttt<<endl;
			temp += ttt;
			sp += ss;
			cp += cc;
			cntp ++;
		}
		
		temp /= N-1;
		temp *= 2.0;
		temp /= N-2;
		ans += temp/N;
	}
	
	ans /= 2.0;
	
	cout<<fixed<<setprecision(12)<<-ans<<endl;
	
	return 0;
}
0