結果
問題 | No.2493 K-th in L2 with L1 |
ユーザー |
![]() |
提出日時 | 2023-11-24 20:48:02 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 1,144 bytes |
コンパイル時間 | 2,137 ms |
コンパイル使用メモリ | 199,136 KB |
最終ジャッジ日時 | 2025-02-17 23:37:57 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 4 |
ソースコード
#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";}continue;}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";}}