結果

問題 No.869 ふたつの距離
ユーザー tempura_pptempura_pp
提出日時 2019-08-15 20:25:17
言語 C++14
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 705 ms / 1,500 ms
コード長 3,403 bytes
コンパイル時間 1,078 ms
使用メモリ 3,780 KB
最終ジャッジ日時 2022-11-18 06:02:18
合計ジャッジ時間 12,234 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 2 ms
3,560 KB
testcase_01 AC 1 ms
3,556 KB
testcase_02 AC 1 ms
3,560 KB
testcase_03 AC 1 ms
3,576 KB
testcase_04 AC 2 ms
3,572 KB
testcase_05 AC 2 ms
3,588 KB
testcase_06 AC 1 ms
3,532 KB
testcase_07 AC 1 ms
3,576 KB
testcase_08 AC 1 ms
3,640 KB
testcase_09 AC 1 ms
3,668 KB
testcase_10 AC 1 ms
3,672 KB
testcase_11 AC 1 ms
3,572 KB
testcase_12 AC 1 ms
3,556 KB
testcase_13 AC 2 ms
3,568 KB
testcase_14 AC 2 ms
3,556 KB
testcase_15 AC 2 ms
3,716 KB
testcase_16 AC 2 ms
3,632 KB
testcase_17 AC 3 ms
3,572 KB
testcase_18 AC 1 ms
3,636 KB
testcase_19 AC 1 ms
3,672 KB
testcase_20 AC 2 ms
3,556 KB
testcase_21 AC 1 ms
3,632 KB
testcase_22 AC 1 ms
3,560 KB
testcase_23 AC 2 ms
3,552 KB
testcase_24 AC 2 ms
3,648 KB
testcase_25 AC 1 ms
3,636 KB
testcase_26 AC 1 ms
3,548 KB
testcase_27 AC 2 ms
3,540 KB
testcase_28 AC 2 ms
3,552 KB
testcase_29 AC 1 ms
3,556 KB
testcase_30 AC 2 ms
3,560 KB
testcase_31 AC 2 ms
3,584 KB
testcase_32 AC 2 ms
3,560 KB
testcase_33 AC 1 ms
3,632 KB
testcase_34 AC 2 ms
3,680 KB
testcase_35 AC 1 ms
3,532 KB
testcase_36 AC 2 ms
3,628 KB
testcase_37 AC 2 ms
3,688 KB
testcase_38 AC 2 ms
3,556 KB
testcase_39 AC 2 ms
3,656 KB
testcase_40 AC 2 ms
3,660 KB
testcase_41 AC 2 ms
3,572 KB
testcase_42 AC 40 ms
3,732 KB
testcase_43 AC 40 ms
3,628 KB
testcase_44 AC 31 ms
3,724 KB
testcase_45 AC 16 ms
3,620 KB
testcase_46 AC 4 ms
3,600 KB
testcase_47 AC 4 ms
3,620 KB
testcase_48 AC 18 ms
3,612 KB
testcase_49 AC 14 ms
3,736 KB
testcase_50 AC 9 ms
3,588 KB
testcase_51 AC 3 ms
3,668 KB
testcase_52 AC 2 ms
3,548 KB
testcase_53 AC 14 ms
3,580 KB
testcase_54 AC 187 ms
3,664 KB
testcase_55 AC 35 ms
3,676 KB
testcase_56 AC 3 ms
3,548 KB
testcase_57 AC 9 ms
3,604 KB
testcase_58 AC 3 ms
3,652 KB
testcase_59 AC 18 ms
3,704 KB
testcase_60 AC 171 ms
3,636 KB
testcase_61 AC 8 ms
3,592 KB
testcase_62 AC 11 ms
3,624 KB
testcase_63 AC 25 ms
3,712 KB
testcase_64 AC 5 ms
3,568 KB
testcase_65 AC 159 ms
3,712 KB
testcase_66 AC 7 ms
3,676 KB
testcase_67 AC 130 ms
3,664 KB
testcase_68 AC 13 ms
3,644 KB
testcase_69 AC 235 ms
3,684 KB
testcase_70 AC 44 ms
3,736 KB
testcase_71 AC 21 ms
3,644 KB
testcase_72 AC 327 ms
3,632 KB
testcase_73 AC 27 ms
3,656 KB
testcase_74 AC 262 ms
3,648 KB
testcase_75 AC 12 ms
3,704 KB
testcase_76 AC 14 ms
3,656 KB
testcase_77 AC 17 ms
3,640 KB
testcase_78 AC 283 ms
3,724 KB
testcase_79 AC 94 ms
3,648 KB
testcase_80 AC 261 ms
3,728 KB
testcase_81 AC 24 ms
3,640 KB
testcase_82 AC 294 ms
3,656 KB
testcase_83 AC 172 ms
3,760 KB
testcase_84 AC 397 ms
3,696 KB
testcase_85 AC 294 ms
3,764 KB
testcase_86 AC 174 ms
3,668 KB
testcase_87 AC 400 ms
3,780 KB
testcase_88 AC 551 ms
3,648 KB
testcase_89 AC 705 ms
3,616 KB
testcase_90 AC 17 ms
3,616 KB
testcase_91 AC 8 ms
3,636 KB
testcase_92 AC 627 ms
3,680 KB
testcase_93 AC 2 ms
3,576 KB
testcase_94 AC 2 ms
3,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


struct Xor128{
    unsigned x,y,z,w;

    Xor128(unsigned w_=88675123):x(123456789),y(362436069),z(521288629),w(w_){};

    inline unsigned xor128(){
        unsigned t;
        t = x^(x<<11);
        x = y;
        y = z;
        z = w;
        return w = (w^(w>>19))^(t^(t>>8));
    }

    int nextInt(int x,int y){
        if(x>y)swap(x,y);
        return xor128()%(y-x)+x;
    }

    double nextDouble(double a,double b){
        return (double)(xor128()&0xffff)/0xffff*(b-a)+a;
    }

};
int main(){
    cout<<fixed<<setprecision(10);
    int n,a,b;
    cin>>n>>a>>b;
    auto rnd = Xor128();
    REP(i,1,n){
        int x = i, y = n-i;
        int B = x*(x-1)/2+y*(y-1)/2;
        if(B>b)continue;
        double l1 = 0, l2 = 0, r1=1, r2=1;
        vector<double> rx(2), ry(2);
        rx[1]=ry[1]=19.95;
        rep(i,x-2)rx.push_back(rnd.nextDouble(0,19.95));
        rep(i,y-2)ry.push_back(rnd.nextDouble(0,19.95));
        sort(rx.begin(),rx.end());
        sort(ry.begin(),ry.end());
        rep(_,25){
            double m1 = (l1+r1)/2, m2 = (l2+r2)/2;
            vector<double> xs(x), ys(y);
            rep(i,x)xs[i]=m1*rx[i];
            rep(i,y)ys[i]=m2*ry[i];
            int s =x*(x-1)/2+y*(y-1)/2;
            rep(i,x){
                s -= xs.end()-upper_bound(xs.begin(),xs.end(),xs[i]+10);
            }
            rep(i,y){
                s -= ys.end()-upper_bound(ys.begin(),ys.end(),ys[i]+10);
            }
            if(s==a)break;
            if(s<a)r1=m1, r2=m2;
            else l1=m1, l2=m2;
        }
        double m1 = (l1+r1)/2, m2 = (l2+r2)/2;
        vector<double> xs(x), ys(y);
        rep(i,x)xs[i]=m1*rx[i];
        rep(i,y)ys[i]=m2*ry[i];
        int s = x*(x-1)/2+y*(y-1)/2;
        rep(i,x){
            s -= xs.end()-upper_bound(xs.begin(),xs.end(),xs[i]+10);
        }
        rep(i,y){
            s -= ys.end()-upper_bound(ys.begin(),ys.end(),ys[i]+10);
        }
        if(s!=a)continue;
        double l = 0, r = 40;
        double h = 10.1;
        rep(_,30){
            double m = (l+r)/2;
            int cnt = 0;
            rep(i,x)rep(j,y){
                if(h*h+(xs[i]-ys[j]-m)*(xs[i]-ys[j]-m)<=400)++cnt;
            }
            if(B+cnt==b){
                vector<double> X, Y;
                rep(i,x)X.push_back(0),Y.push_back(xs[i]);
                rep(i,y)X.push_back(h),Y.push_back(ys[i]+m);
                int cntA = 0, cntB = 0;
                rep(i,n)rep(j,i){
                    if((X[i]-X[j])*(X[i]-X[j])+(Y[i]-Y[j])*(Y[i]-Y[j])<=100)++cntA;
                    if((X[i]-X[j])*(X[i]-X[j])+(Y[i]-Y[j])*(Y[i]-Y[j])<=400)++cntB;
                }
                if(cntA==a&&cntB==b){
                    rep(i,x)cout<<0<<" "<<xs[i]<<endl;
                    rep(i,y)cout<<h<<" "<<ys[i]+m<<endl;
                    return 0;
                }
            }
            if(B+cnt>b)l=m;
            else r=m;
        }

    }

    return 0;
}
0