結果
問題 | No.2493 K-th in L2 with L1 |
ユーザー |
👑 |
提出日時 | 2023-10-06 21:50:51 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 1,554 bytes |
コンパイル時間 | 3,763 ms |
コンパイル使用メモリ | 258,944 KB |
最終ジャッジ日時 | 2025-02-17 04:59:34 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 4 |
ソースコード
#include<bits/stdc++.h>#include<atcoder/all>#define rep(i,n) for(int i=0;i<n;i++)using namespace std;using namespace atcoder;typedef long long ll;typedef vector<int> vi;typedef vector<long long> vl;typedef vector<vector<int>> vvi;typedef vector<vector<long long>> vvl;typedef pair<int,int> P;typedef long double ld;template<typename T>istream& operator>>(istream& is, vector<T>& v){int n = v.size(); assert(n > 0); rep(i, n) is >> v[i]; return is;}template<typename T>ostream& operator<<(ostream& os, const vector<T>& v){int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "\n" : " "); return os;}template <typename T>ostream& operator<<(ostream& os, const vector<vector<T>>& v){int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "\n" : ""); return os;}void solve(){int d, k;cin >> d >> k;if(d == 0){if(k == 1) cout << "Yes\n0 0\n";else cout << "No\n";return;}if(k > 4 * d){cout << "No\n";return;}vector<tuple<int, int, int>> a;rep(x, d){int y = d - x;a.emplace_back(x * x + y * y, x, y);}for(int y = 0; y > -d; y--){int x = d + y;a.emplace_back(x * x + y * y, x, y);}for(int x = 0; x > -d; x--){int y = -d - x;a.emplace_back(x * x + y * y, x, y);}rep(y, d){int x = -d + y;a.emplace_back(x * x + y * y, x, y);}sort(a.begin(), a.end());/*for(auto [tmp, x, y] : a){cout << x << ' ' << y << "\n";}*/auto [tmp, x, y] = a[k - 1];cout << "Yes\n";cout << x << ' ' << y << "\n";}int main(){int t;cin >> t;rep(_, t) solve();return 0;}