結果

問題 No.2493 K-th in L2 with L1
ユーザー forest3forest3
提出日時 2024-01-15 22:21:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 804 bytes
コンパイル時間 5,765 ms
コンパイル使用メモリ 175,716 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-01-15 22:22:01
合計ジャッジ時間 2,839 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)

int main() {
	int Q;
	cin >> Q;
	using P = pair<int, int>;
	using PP = pair<ll, P>;
	rep(i, Q) {
		int d, k;
		cin >> d >> k;
		vector<PP> v;
		for(ll x = -d; x <= d; x++ ) {
			ll y = d - abs(x);
			if(y) {
				P p;
				p.first = x;
				p.second = y;
				ll ud = x * x + y * y;
				v.push_back(PP(ud, p));
				p.second = -y;
				v.push_back(PP(ud, p));
			}
			else {
				P p;
				p.first = x;
				p.second = 0;
				ll ud = x * x;
				v.push_back(PP(ud, p));
			}
		}
		if((int)v.size() < k) cout << "No" << endl;
		else {
			sort(v.begin(), v.end());
			cout << "Yes" << endl;
			k--;
			ll x = v[k].second.first;
			ll y = v[k].second.second;
			cout << x << " " << y << endl;
		}
	}
}
0