結果

問題 No.2493 K-th in L2 with L1
ユーザー a01sa01toa01sa01to
提出日時 2024-04-12 00:37:00
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 961 bytes
コンパイル時間 3,978 ms
コンパイル使用メモリ 287,328 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-12 00:37:05
合計ジャッジ時間 4,962 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 4 ms
6,944 KB
testcase_02 AC 5 ms
6,944 KB
testcase_03 AC 3 ms
6,944 KB
testcase_04 AC 1 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
  #include "settings/debug.cpp"
  #define _GLIBCXX_DEBUG
#else
  #define Debug(...) void(0)
#endif
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;

int main() {
  int q;
  cin >> q;
  while (q--) {
    int d, k;
    cin >> d >> k;
    set<pair<int, int>> _v;
    for (int x = -d; x <= d; x++) {
      int y = d - abs(x);
      _v.insert({ x, y });
      _v.insert({ x, -y });
    }
    vector<pair<int, int>> v(_v.begin(), _v.end());
    sort(v.begin(), v.end(), [](pair<int, int> a, pair<int, int> b) {
      int da = a.first * a.first + a.second * a.second;
      int db = b.first * b.first + b.second * b.second;
      return da < db;
    });
    Debug(v);
    if (v.size() < k) {
      cout << "No" << endl;
    }
    else {
      auto [x, y] = v[k - 1];
      cout << "Yes" << endl;
      cout << x << " " << y << endl;
    }
  }
  return 0;
}
0