結果

問題 No.2493 K-th in L2 with L1
ユーザー t98slidert98slider
提出日時 2023-12-27 05:13:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 962 bytes
コンパイル時間 2,281 ms
コンパイル使用メモリ 213,432 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-12-27 05:13:36
合計ジャッジ時間 3,315 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int Q;
    cin >> Q;
    auto f = [&](pair<int,int> x){
        return x.first * x.first + x.second * x.second;
    };
    while(Q--){
        int D, K;
        cin >> D >> K;
        vector<pair<int,int>> p;
        p.reserve(4 * D);
        for(int i = 0; i <= D; i++){
            p.emplace_back(i, D - i);
            p.emplace_back(i, -(D - i));
            p.emplace_back(D - i, i);
            p.emplace_back(-(D - i), i);
        }
        sort(p.begin(), p.end());
        p.erase(unique(p.begin(), p.end()), p.end());
        sort(p.begin(), p.end(), [&](pair<int,int> lhs, pair<int,int> rhs){
            return f(lhs) < f(rhs);
        });
        K--;
        if(K >= p.size()){
            cout << "No\n";
            continue;
        }
        cout << "Yes\n" << p[K].first << ' ' << p[K].second << '\n';
    }
}
0