結果

問題 No.2493 K-th in L2 with L1
ユーザー bortikbortik
提出日時 2023-10-06 21:37:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 925 bytes
コンパイル時間 2,096 ms
コンパイル使用メモリ 207,700 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-10-06 21:37:33
合計ジャッジ時間 2,925 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, n, a) for (int i = (int)(n); i >= (int)(a); i--)

void solve(){
    int d,k; cin >> d >> k;
    vector<pair<int, pair<int,int>>> dist;
    rep(i,0,d){ 
        int x = i;
        int y = d-i;
        dist.push_back(make_pair(x*x+y*y, make_pair(x,y)));
        dist.push_back(make_pair(x*x+y*y, make_pair(-x,y)));
        dist.push_back(make_pair(x*x+y*y, make_pair(x,-y)));
        dist.push_back(make_pair(x*x+y*y, make_pair(-x,-y)));
    }
    sort(dist.begin(), dist.end());
    if(dist.size() < k){
        cout << "No";
    } else{
        cout << "Yes\n" << dist[k-1].second.first << " " << dist[k-1].second.second;
    }
    cout << '\n';

}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin >> t;
    rep(i,0,t) solve();

    return 0;
}
0