結果
問題 | No.2493 K-th in L2 with L1 |
ユーザー |
![]() |
提出日時 | 2024-01-15 22:21:50 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 804 bytes |
コンパイル時間 | 1,658 ms |
コンパイル使用メモリ | 175,716 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-28 02:23:47 |
合計ジャッジ時間 | 2,298 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 4 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;#define rep(i, n) for(int i = 0; i < n; i++)int main() {int Q;cin >> Q;using P = pair<int, int>;using PP = pair<ll, P>;rep(i, Q) {int d, k;cin >> d >> k;vector<PP> v;for(ll x = -d; x <= d; x++ ) {ll y = d - abs(x);if(y) {P p;p.first = x;p.second = y;ll ud = x * x + y * y;v.push_back(PP(ud, p));p.second = -y;v.push_back(PP(ud, p));}else {P p;p.first = x;p.second = 0;ll ud = x * x;v.push_back(PP(ud, p));}}if((int)v.size() < k) cout << "No" << endl;else {sort(v.begin(), v.end());cout << "Yes" << endl;k--;ll x = v[k].second.first;ll y = v[k].second.second;cout << x << " " << y << endl;}}}