結果
| 問題 |
No.2493 K-th in L2 with L1
|
| ユーザー |
|
| 提出日時 | 2023-10-12 18:07:25 |
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 1,072 bytes |
| コンパイル時間 | 1,173 ms |
| コンパイル使用メモリ | 131,304 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-14 16:36:25 |
| 合計ジャッジ時間 | 1,693 ms |
|
ジャッジサーバーID (参考情報) |
judge6 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 4 |
ソースコード
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
using i64 = long long;
using P = pair<int, int>;
#define yn(pope) (pope ? "Yes" : "No")
#define rep(i, n, m) for (int i = (n); i < (m); i++)
#define rrep(i, n, m) for (int i = (n); i > m; i--)
#define IINF (1 << 30)
#define INF (1ll << 60)
#define all(v) v.begin(), v.end()
int main() {
int Q;
cin >> Q;
auto f = [](P a, P b) -> bool {
int a_ = a.first * a.first + a.second * a.second;
int b_ = b.first * b.first + b.second * b.second;
return a_ < b_;
};
while (Q--) {
int d, k;
cin >> d >> k;
vector<P> G;
rep(i, 0, d + 1) {
G.push_back({i, d - i});
G.push_back({-i, d - i});
G.push_back({i, i - d});
G.push_back({-i, i - d});
}
sort(all(G));
G.erase(unique(all(G)), G.end());
sort(all(G), f);
if (G.size() < k) {
cout << "No" << endl;
} else {
k--;
cout << "Yes" << endl;
cout << G[k].first << " " << G[k].second << endl;
}
}
return 0;
}