結果

問題 No.2493 K-th in L2 with L1
ユーザー soldraysoldray
提出日時 2023-10-12 18:05:27
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,061 bytes
コンパイル時間 2,483 ms
コンパイル使用メモリ 96,968 KB
実行使用メモリ 4,480 KB
最終ジャッジ日時 2023-10-12 18:05:32
合計ジャッジ時間 3,774 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#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 {
      cout << "Yes" << endl;
      cout << G[k].first << " " << G[k].second << endl;
    }
  }

  return 0;
}
0