結果
問題 | No.2493 K-th in L2 with L1 |
ユーザー |
![]() |
提出日時 | 2024-04-12 00:37:00 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 5 ms / 2,000 ms |
コード長 | 961 bytes |
コンパイル時間 | 3,346 ms |
コンパイル使用メモリ | 257,712 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-02 21:46:04 |
合計ジャッジ時間 | 4,390 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 4 |
ソースコード
#include <bits/stdc++.h>using namespace std;#ifdef LOCAL#include "settings/debug.cpp"#define _GLIBCXX_DEBUG#else#define Debug(...) void(0)#endif#define rep(i, n) for (int i = 0; i < (n); ++i)using ll = long long;using ull = unsigned long long;int main() {int q;cin >> q;while (q--) {int d, k;cin >> d >> k;set<pair<int, int>> _v;for (int x = -d; x <= d; x++) {int y = d - abs(x);_v.insert({ x, y });_v.insert({ x, -y });}vector<pair<int, int>> v(_v.begin(), _v.end());sort(v.begin(), v.end(), [](pair<int, int> a, pair<int, int> b) {int da = a.first * a.first + a.second * a.second;int db = b.first * b.first + b.second * b.second;return da < db;});Debug(v);if (v.size() < k) {cout << "No" << endl;}else {auto [x, y] = v[k - 1];cout << "Yes" << endl;cout << x << " " << y << endl;}}return 0;}