結果

問題 No.2493 K-th in L2 with L1
ユーザー yansi819yansi819
提出日時 2024-03-17 11:40:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 889 bytes
コンパイル時間 5,118 ms
コンパイル使用メモリ 274,348 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-17 11:40:07
合計ジャッジ時間 5,728 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;

int Q, D, K;

double dist(int x, int y) {
  return sqrt(x * x + y * y);
}

void solve() {
  cin >> D >> K;
  vector<pair<double, pair<int, int>>> vec;
  set<pair<int, int>> st;
  for (int x = -D; x <= D; x++) {
    int y = D - abs(x);
    double d = dist(x, y);
    if (st.count({x, y}) == 0) {
      vec.push_back({d, {x, y}});
      st.insert({x, y});
    }
    y = abs(x) - D;
    d = dist(x, y);
    if (st.count({x, y}) == 0) {
      vec.push_back({d, {x, y}});
      st.insert({x, y});
    }
  }
  if (vec.size() < K) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
    sort(vec.begin(), vec.end());
    cout << vec[K - 1].second.first << ' ' << vec[K - 1].second.second << endl;
  }
}

int main(void){
  cin >> Q;
  while(Q--) {
    solve();
  }
}
0