結果

問題 No.2493 K-th in L2 with L1
ユーザー yelyel
提出日時 2023-10-06 23:24:13
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 994 bytes
コンパイル時間 3,454 ms
コンパイル使用メモリ 258,860 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-10-06 23:24:18
合計ジャッジ時間 4,140 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
typedef long long ll;
typedef unsigned long long ull;
const int MAX = 1e9;
const int MIN = -1*1e9;
const ll MAXLL = 1e18;
const ll MINLL = -1*1e18;
//const ll MOD = 998244353;
//const ll MOD = 1000000007;
int main()
{
    int Q; cin >> Q;
    for(int q = 0; q < Q; q++)
    {
        int A,B; cin >> A >> B;
        vector<pair<int,string>> Ans;
        for(int i = -A; i <= A; i++)
        {
            for(int j = -A; j <= A; j++)
            {
                if(abs(i)+abs(j)==A)
                {
                    Ans.push_back({abs(i)*abs(i)+abs(j)*abs(j),(to_string(i)+" "+to_string(j))});
                }
            }
        }
        sort(Ans.begin(),Ans.end());
        if(Ans.size() < B)
        {
            cout << "No" << endl;
        }
        else
        {
            cout << "Yes" << endl;
            cout << Ans[B-1].second << endl;
        } 
    }
    return 0;
}
0