結果
問題 | No.2493 K-th in L2 with L1 |
ユーザー |
|
提出日時 | 2024-03-17 11:40:01 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 5 ms / 2,000 ms |
コード長 | 889 bytes |
コンパイル時間 | 3,826 ms |
コンパイル使用メモリ | 262,804 KB |
最終ジャッジ日時 | 2025-02-20 07:01:28 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 4 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; using ll = long long; int Q, D, K; double dist(int x, int y) { return sqrt(x * x + y * y); } void solve() { cin >> D >> K; vector<pair<double, pair<int, int>>> vec; set<pair<int, int>> st; for (int x = -D; x <= D; x++) { int y = D - abs(x); double d = dist(x, y); if (st.count({x, y}) == 0) { vec.push_back({d, {x, y}}); st.insert({x, y}); } y = abs(x) - D; d = dist(x, y); if (st.count({x, y}) == 0) { vec.push_back({d, {x, y}}); st.insert({x, y}); } } if (vec.size() < K) { cout << "No" << endl; } else { cout << "Yes" << endl; sort(vec.begin(), vec.end()); cout << vec[K - 1].second.first << ' ' << vec[K - 1].second.second << endl; } } int main(void){ cin >> Q; while(Q--) { solve(); } }