結果
問題 | No.2493 K-th in L2 with L1 |
ユーザー |
![]() |
提出日時 | 2023-10-06 21:27:32 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 6 ms / 2,000 ms |
コード長 | 813 bytes |
コンパイル時間 | 1,057 ms |
コンパイル使用メモリ | 94,296 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-26 15:42:53 |
合計ジャッジ時間 | 1,628 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 4 |
ソースコード
#include <iostream>#include <string>#include <algorithm>#include <functional>#include <vector>#include <stack>#include <queue>#include <set>#include <map>#include <cstdio>#include <cmath>#include <tuple>#include <cassert>#define int long long#define rep(i, n) for(i = 0; i < n; i++)using namespace std;signed main() {int q;cin >> q;while (q--) {int d, K;cin >> d >> K;K--;typedef tuple<int, int, int> T;vector<T> vec;for (int y = -d; y <= d; y++) {for (int x = -d; x <= d; x++) {if (abs(x) + abs(y) != d) continue;vec.push_back(T(x * x + y * y, x, y));}}sort(vec.begin(), vec.end());if (K >= vec.size()) { cout << "No" << endl; }else {cout << "Yes" << endl;cout << get<1>(vec[K]) << " " << get<2>(vec[K]) << endl;}}return 0;}