結果

問題 No.2493 K-th in L2 with L1
ユーザー myaumyau
提出日時 2023-10-06 21:29:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,616 bytes
コンパイル時間 4,443 ms
コンパイル使用メモリ 264,884 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-10-06 21:29:32
合計ジャッジ時間 5,186 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

//only for atcoder
#include<atcoder/all>
using namespace atcoder;

#define rep(i,l,r) for(ll i=(l); i<(r); i++)
#define rrep(i,l,r) for(ll i=(r)-1; i>=(l); i--)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define REV(c) reverse(ALL(c))
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define MINV(c) *min_element(ALL(c))
#define MAXV(c) *max_element(ALL(c))

template <typename TYPE>
void print(TYPE vec){
  rep(i,0,vec.size()){
    cout << vec[i];
    if(i == vec.size()-1){
      cout << endl;
    }
    else{
      cout << " ";
    }
  }
}

using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VS = vector<string>;
using VVS = vector<VS>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VC = vector<char>;
using VVC = vector<VC>;
using VD = vector<ld>;
using VVD = vector<VD>;
using P = pair<ll,ll>;
using VP = vector<P>;
using VVP = vector<VP>;
const ll LINF = 2e18;
const int INF = 2e9;

bool comp(P a, P b){
  auto[x1,y1] = a;
  auto[x2,y2] = b;
  return x1*x1 + y1*y1 < x2*x2 + y2*y2;
}

void solve(){
  int D, K;
  cin >> D >> K;
  VP vec(0);
  rep(i,-D,D+1){
    int A = D - abs(i);
    vec.push_back(P(i, A));
    if(A != 0){
      vec.push_back(P(i, -A));
    }
  }
  sort(ALL(vec), comp);
  if(vec.size() < K){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
    cout << vec[K-1].first << " " << vec[K-1].second << endl;
  }
}

int main(){
  int T;
  cin >> T;
  rep(i,0,T){
    solve();
  }
}
0