結果

問題 No.2493 K-th in L2 with L1
ユーザー askr58askr58
提出日時 2023-10-06 21:29:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 804 bytes
コンパイル時間 4,378 ms
コンパイル使用メモリ 264,904 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-10-06 21:29:33
合計ジャッジ時間 4,858 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 3 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;

int main()
{
    int q;
    cin>>q;
    for(int i=0;i<q;i++){
        int d,k;
        cin>>d>>k;
        vector<pair<int,int>> p;
        for(int j=0;j<=d;j++){
            p.push_back({j,d-j});
            if(j!=0)p.push_back({-j,d-j});
            if(j!=d)p.push_back({j,j-d});
            if(j!=0&&j!=d)p.push_back({-j,j-d});
        }
        sort(p.begin(),p.end(),[](pair<int,int> a,pair<int,int> b){
            int xa=a.first,ya=a.second,xb=b.first,yb=b.second;
            return xa*xa+ya*ya<xb*xb+yb*yb;

        });
        if(p.size()<k)cout<<"No"<<endl;
        else {
            cout<<"Yes"<<endl;
            cout<<p[k-1].first<<" "<<p[k-1].second<<endl;
        }
    }
}
0