結果
問題 | No.2493 K-th in L2 with L1 |
ユーザー |
![]() |
提出日時 | 2023-10-08 16:40:24 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 837 bytes |
コンパイル時間 | 455 ms |
コンパイル使用メモリ | 53,248 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-26 18:08:56 |
合計ジャッジ時間 | 1,011 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 4 |
ソースコード
/* -*- coding: utf-8 -*-** 2493.cc: No.2493 K-th in L2 with L1 - yukicoder*/#include<cstdio>#include<tuple>#include<algorithm>using namespace std;/* constant */const int MAX_D = 100;/* typedef */typedef tuple<int,int,int> trpl;/* global variables */trpl ps[MAX_D * 4];/* subroutines *//* main */int main() {int qn;scanf("%d", &qn);while (qn--) {int di, ki;scanf("%d%d", &di, &ki), ki--;int n = 0;if (di == 0)ps[n++] = {0, 0, 0};else {for (int y = -di; y <= di; y++) {int x0 = di - abs(y), x1 = -x0;int d2 = x0 * x0 + y * y;ps[n++] = {d2, x0, y};if (x1 != x0) ps[n++] = {d2, x1, y};}sort(ps, ps + n);}if (ki < n)printf("Yes\n%d %d\n", get<1>(ps[ki]), get<2>(ps[ki]));elseputs("No");}return 0;}