結果

問題 No.2493 K-th in L2 with L1
ユーザー startcppstartcpp
提出日時 2023-10-06 21:27:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 813 bytes
コンパイル時間 909 ms
コンパイル使用メモリ 92,636 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-10-06 21:27:34
合計ジャッジ時間 1,525 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <cassert>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

signed main() {
	int q;
	cin >> q;
	while (q--) {
		int d, K;
		cin >> d >> K;
		K--;

		typedef tuple<int, int, int> T;
		vector<T> vec;
		for (int y = -d; y <= d; y++) {
			for (int x = -d; x <= d; x++) {
				if (abs(x) + abs(y) != d) continue;
				vec.push_back(T(x * x + y * y, x, y));
			}
		}
		sort(vec.begin(), vec.end());
		if (K >= vec.size()) { cout << "No" << endl; }
		else {
			cout << "Yes" << endl;
			cout << get<1>(vec[K]) << " " << get<2>(vec[K]) << endl;
		}
	}
	return 0;
}
0