結果

問題 No.2493 K-th in L2 with L1
ユーザー Nzt3Nzt3
提出日時 2023-10-07 14:55:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 730 bytes
コンパイル時間 2,249 ms
コンパイル使用メモリ 205,864 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-10-07 14:55:25
合計ジャッジ時間 2,969 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
void solve(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int D,K;
  cin>>D>>K;
  vector A(0,array<int,2>());
  if(D==0){
    A.push_back({0,0});
  }
  for(int i=0;i<D;i++){
    A.push_back({i,D-i});
    A.push_back({D-i,-i});
    A.push_back({-i,-D+i});
    A.push_back({-D+i,i});
  }
  sort(A.begin(),A.end(),[](array<int,2>a,array<int,2>b){
    return a[0]*a[0]+a[1]*a[1]<b[0]*b[0]+b[1]*b[1];
  });
  if(K>A.size()){
    cout<<"No\n";
  }else{
    cout<<"Yes\n";
    cout<<A[K-1][0]<<' '<<A[K-1][1]<<'\n';
  }
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int test_case;
  cin>>test_case;
  while (test_case--){
    solve();
  }
}
0