結果
| 問題 | No.2493 K-th in L2 with L1 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2023-10-06 21:29:28 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 804 bytes | 
| コンパイル時間 | 3,489 ms | 
| コンパイル使用メモリ | 255,232 KB | 
| 最終ジャッジ日時 | 2025-02-17 04:49:16 | 
| ジャッジサーバーID (参考情報) | judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 4 | 
ソースコード
#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;
        }
    }
}
            
            
            
        