結果

問題 No.2493 K-th in L2 with L1
ユーザー nono00nono00
提出日時 2023-10-06 21:41:08
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,063 bytes
コンパイル時間 3,132 ms
コンパイル使用メモリ 263,620 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-10-06 21:41:12
合計ジャッジ時間 3,779 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

namespace nono {

void solve() {
    constexpr int D = 100;
    std::vector good_points(D + 1, std::vector<std::tuple<int, int, int>>());
    for (int i = -D; i <= D; i++) {
        for (int j = -D; j <= D; j++) {
            int d = std::abs(i) + std::abs(j);
            if (d <= D) {
                good_points[d].emplace_back(i * i + j * j, i, j);
            }
        }
    }
    for (int i = 0; i <= D; i++) {
        std::ranges::sort(good_points[i]);
    }
    int q;
    std::cin >> q;
    while (q--) {
        int d, k;
        std::cin >> d >> k;
        if ((int)good_points[d].size() >= k) {
            std::cout << "Yes" << std::endl;
            std::cout << std::get<1>(good_points[d][k - 1]) << ' ' << std::get<2>(good_points[d][k - 1]) << std::endl;
        } else {
            std::cout << "No" << std::endl;
        }
    }
}

}  //  namespace nono

int main() {
    std::cin.tie(0)->sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);

    int t = 1;

    while (t--) nono::solve();
}
0