結果

問題 No.869 ふたつの距離
ユーザー 👑 kmjpkmjp
提出日時 2020-08-19 02:25:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 179 ms / 1,500 ms
コード長 2,112 bytes
コンパイル時間 2,599 ms
コンパイル使用メモリ 208,260 KB
実行使用メモリ 13,176 KB
最終ジャッジ日時 2024-04-20 08:07:25
合計ジャッジ時間 10,464 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 1 ms
6,944 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 1 ms
6,944 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 1 ms
6,940 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 1 ms
6,940 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 1 ms
6,944 KB
testcase_23 AC 1 ms
6,944 KB
testcase_24 AC 1 ms
6,940 KB
testcase_25 AC 2 ms
6,940 KB
testcase_26 AC 2 ms
6,944 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 2 ms
6,940 KB
testcase_29 AC 2 ms
6,940 KB
testcase_30 AC 1 ms
6,940 KB
testcase_31 AC 1 ms
6,940 KB
testcase_32 AC 2 ms
6,940 KB
testcase_33 AC 2 ms
6,944 KB
testcase_34 AC 2 ms
6,940 KB
testcase_35 AC 2 ms
6,944 KB
testcase_36 AC 2 ms
6,944 KB
testcase_37 AC 2 ms
6,944 KB
testcase_38 AC 1 ms
6,940 KB
testcase_39 AC 2 ms
6,944 KB
testcase_40 AC 2 ms
6,944 KB
testcase_41 AC 2 ms
6,944 KB
testcase_42 AC 114 ms
6,944 KB
testcase_43 AC 31 ms
6,944 KB
testcase_44 AC 44 ms
6,940 KB
testcase_45 AC 78 ms
6,940 KB
testcase_46 AC 5 ms
6,940 KB
testcase_47 AC 24 ms
6,944 KB
testcase_48 AC 47 ms
6,944 KB
testcase_49 AC 51 ms
6,940 KB
testcase_50 AC 29 ms
6,940 KB
testcase_51 AC 6 ms
6,940 KB
testcase_52 AC 3 ms
6,940 KB
testcase_53 AC 15 ms
6,940 KB
testcase_54 AC 100 ms
8,456 KB
testcase_55 AC 61 ms
6,944 KB
testcase_56 AC 19 ms
6,940 KB
testcase_57 AC 46 ms
6,940 KB
testcase_58 AC 9 ms
6,940 KB
testcase_59 AC 13 ms
6,944 KB
testcase_60 AC 91 ms
7,808 KB
testcase_61 AC 35 ms
6,944 KB
testcase_62 AC 100 ms
6,944 KB
testcase_63 AC 120 ms
7,948 KB
testcase_64 AC 25 ms
6,940 KB
testcase_65 AC 68 ms
8,064 KB
testcase_66 AC 59 ms
6,940 KB
testcase_67 AC 135 ms
12,344 KB
testcase_68 AC 152 ms
8,332 KB
testcase_69 AC 143 ms
8,836 KB
testcase_70 AC 152 ms
9,224 KB
testcase_71 AC 149 ms
8,068 KB
testcase_72 AC 139 ms
12,172 KB
testcase_73 AC 145 ms
8,328 KB
testcase_74 AC 148 ms
8,584 KB
testcase_75 AC 158 ms
6,940 KB
testcase_76 AC 143 ms
8,072 KB
testcase_77 AC 138 ms
12,628 KB
testcase_78 AC 141 ms
12,212 KB
testcase_79 AC 139 ms
13,100 KB
testcase_80 AC 148 ms
12,036 KB
testcase_81 AC 141 ms
12,156 KB
testcase_82 AC 144 ms
9,224 KB
testcase_83 AC 153 ms
7,820 KB
testcase_84 AC 140 ms
7,812 KB
testcase_85 AC 147 ms
8,452 KB
testcase_86 AC 153 ms
7,820 KB
testcase_87 AC 145 ms
8,076 KB
testcase_88 AC 146 ms
8,324 KB
testcase_89 AC 160 ms
8,588 KB
testcase_90 AC 151 ms
8,068 KB
testcase_91 AC 179 ms
6,944 KB
testcase_92 AC 139 ms
13,176 KB
testcase_93 AC 2 ms
6,944 KB
testcase_94 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'void solve()':
main.cpp:52:38: warning: 'V' may be used uninitialized [-Wmaybe-uninitialized]
   52 |         x=A*1.0*U*(U-1)/(U*(U-1)+V*(V-1))+0.5;
      |                                    ~~^~~
main.cpp:47:15: note: 'V' was declared here
   47 |         int U,V;
      |               ^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,A,B;

long double getrandom() {
	int a=rand()%10000;
	int b=rand()%10000;
	return (a*10000+b)/10000000000.0;
}

vector<long double> hoge(int n,int p) {
	vector<long double> T;
	T.push_back(getrandom());
	while(T.size()<n) T.push_back(T.back()+getrandom());
	if(n<2) return T;
	long double L=0,R=17.3/(n-1);
	int i,x,y;
	FOR(i,100) {
		long double M=(L+R)/2.0;
		int num=0;
		FOR(y,n) FOR(x,y) if((T[y]+y*M)-(T[x]+x*M)<=10) num++;
		if(num>=p) L=M;
		else R=M;
	}
	
	FOR(i,n) T[i]+=L*i;
	return T;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	srand(time(NULL));
	cin>>N>>A>>B;
	int U,V;
	for(U=1;U<=N;U++) {
		V=N-U;
		if(U>=V && U*(U-1)/2+V*(V-1)/2>=A) break;
	}
	x=A*1.0*U*(U-1)/(U*(U-1)+V*(V-1))+0.5;
	y=A-x;
	B-=U*(U-1)/2+V*(V-1)/2;
	vector<long double> S=hoge(U,x);
	vector<long double> T=hoge(V,y);
	vector<pair<long double,long double>> R;
	vector<double> C;
	FORR(s,S) FORR(t,T) {
		C.push_back(sqrt((long double)400-(t-s)*(t-s))-0.000000001);
	}
	sort(ALL(C));
	reverse(ALL(C));
	FORR(s,S) R.push_back({s,C[B-1]});
	FORR(t,T) R.push_back({t,0});
	
	/*
	int num[2]={};
	FORR(x,R) FORR(y,R) if(x<y) {
		long double a=x.first-y.first;
		long double b=x.second-y.second;
		if(a*a+b*b<=100.0000000000) num[0]++;
		if(a*a+b*b<=400.0000000000) num[1]++;
	}
	_P("%d %d %d\n",N,num[0],num[1]);
	assert(num[0]==A);
	assert(num[1]==B+U*(U-1)/2+V*(V-1)/2);
	*/
	FORR(r,R) _P("%.12lf %.12lf\n",(double)r.first,(double)r.second);
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0