結果

問題 No.2493 K-th in L2 with L1
ユーザー zezerozezero
提出日時 2023-11-04 13:46:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 856 bytes
コンパイル時間 3,423 ms
コンパイル使用メモリ 173,388 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-11-04 13:46:39
合計ジャッジ時間 4,267 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <cstring>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < int(n);i++)

void solve(){
  int d,k;
  cin >> d >> k;
  vector<pair<int,pair<int,int>>> a;
  for (int x = -d; x <= d;x++){
    for (int y = -d; y <= d;y++){
      if (abs(x)+abs(y) == d){
        a.push_back({x*x+y*y,{x,y}});
      }
    }
  }
  sort(a.begin(),a.end());
  //cout << "size:" << a.size() << endl;
  if (k <= a.size()){
    cout << "Yes\n";
    cout << a[k-1].second.first << " " << a[k-1].second.second << endl; 
  }
  else cout << "No\n";
  return;
}
int main(){
  int q;
  cin >> q;
  while(q--){
    solve();
  }

  return 0;
}
0