結果
問題 | No.2493 K-th in L2 with L1 |
ユーザー | Haa |
提出日時 | 2023-10-06 21:25:53 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 962 bytes |
コンパイル時間 | 1,736 ms |
コンパイル使用メモリ | 173,248 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-10-06 21:25:56 |
合計ジャッジ時間 | 2,242 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 4 ms
4,380 KB |
testcase_02 | AC | 4 ms
4,376 KB |
testcase_03 | AC | 4 ms
4,380 KB |
testcase_04 | AC | 1 ms
4,376 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll,ll> P; typedef vector<ll> VI; typedef vector<VI> VVI; #define REP(i,n) for(int i=0;i<(n);i++) #define ALL(v) v.begin(),v.end() template<typename T> bool chmax(T& x, const T& y){return (x<y)?(x=y,true):false;}; template<typename T> bool chmin(T& x, const T& y){return (x>y)?(x=y,true):false;}; constexpr ll MOD=998244353; constexpr ll INF=2e18; int main(){ int q; cin >> q; int d, k; REP(_,q){ cin >> d >> k; vector<pair<int,P>> p; for(int x=-d;x<=d;x++)for(int y=-d;y<=d;y++){ if(abs(x)+abs(y)==d){ p.push_back({x*x+y*y,{x,y}}); } } sort(ALL(p)); int n=p.size(); if(n<k) cout << "No" << endl; else{ cout << "Yes" << endl; cout << p[k-1].second.first << " " << p[k-1].second.second << endl; } } return 0; }