結果

問題 No.2493 K-th in L2 with L1
ユーザー maeshunmaeshun
提出日時 2023-10-06 21:29:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,171 bytes
コンパイル時間 4,362 ms
コンパイル使用メモリ 238,120 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-10-06 21:29:51
合計ジャッジ時間 4,449 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 3 ms
4,376 KB
testcase_02 AC 3 ms
4,376 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:42:18: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   42 |             auto [d, x, y] = vs[k-1];
      |                  ^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define rep(i, n) for(int i=0;i<(n);++i)
#define rep1(i, n) for(int i=1;i<=(n);i++)
#define ll long long
using mint = modint998244353;
using P = pair<ll,ll>;
using lb = long double;
using T = tuple<ll, ll, ll>;
#ifdef LOCAL
#  include <debug_print.hpp>
#  define dbg(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
#  define dbg(...) (static_cast<void>(0))
#endif

int main()
{
    int q;
    cin >> q;
    rep(qi,q){
        int d, k;
        cin >> d >> k;
        vector<T> vs;
        for(int x=0;x<=d;x++){
            int y = d - abs(x);
            int r = x*x + y*y;
            vs.emplace_back(r, x, y);
            vs.emplace_back(r, -x, y);
            vs.emplace_back(r, x, -y);
            vs.emplace_back(r, -x, -y);
        }
        sort(vs.begin(),vs.end());
        vs.erase(unique(vs.begin(),vs.end()),vs.end());
        if(vs.size()<k){
            cout << "No" << endl;
        }
        else{
            cout << "Yes" << endl;
            auto [d, x, y] = vs[k-1];
            cout << x << " " << y << endl;
        }
    }
    return 0;
}
0