結果

問題 No.2493 K-th in L2 with L1
ユーザー eve__fuyukieve__fuyuki
提出日時 2023-11-24 20:47:52
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,122 bytes
コンパイル時間 2,514 ms
コンパイル使用メモリ 208,692 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-11-24 20:47:56
合計ジャッジ時間 3,828 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
void fast_io() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}

int main() {
    fast_io();
    int q;
    cin >> q;
    for (; q--;) {
        int d, k;
        cin >> d >> k;
        if (d == 0) {
            if (k == 1) {
                cout << "Yes\n";
                cout << "0 0\n";
            } else {
                cout << "No\n";
            }
        }
        if (k > 4 * d) {
            cout << "No\n";
            continue;
        }
        vector<pair<int, int>> points;
        for (int x = -d; x <= d; x++) {
            points.push_back({x, d - abs(x)});
            if (x != d && x != -d) {
                points.push_back({x, abs(x) - d});
            }
        }
        sort(points.begin(), points.end(),
             [](const pair<int, int> &a, const pair<int, int> &b) {
                 return a.first * a.first + a.second * a.second <
                        b.first * b.first + b.second * b.second;
             });
        cout << "Yes\n";
        cout << points[k - 1].first << " " << points[k - 1].second << "\n";
    }
}
0