結果
| 問題 | No.2493 K-th in L2 with L1 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2023-10-06 21:24:43 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 4 ms / 2,000 ms | 
| コード長 | 815 bytes | 
| コンパイル時間 | 862 ms | 
| コンパイル使用メモリ | 84,244 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-26 15:40:57 | 
| 合計ジャッジ時間 | 1,286 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 4 | 
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
#include<cassert>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int Q;cin>>Q;
	for(;Q--;)
	{
		int D,K;
		cin>>D>>K;
		vector<pair<int,int> >X;
		for(int x=0;x<=D;x++)
		{
			int y=D-x;
			X.push_back(make_pair(x,y));
			X.push_back(make_pair(x,-y));
			X.push_back(make_pair(-x,y));
			X.push_back(make_pair(-x,-y));
		}
		sort(X.begin(),X.end());
		X.erase(unique(X.begin(),X.end()),X.end());
		vector<pair<int,pair<int,int> > >A(X.size());
		for(int i=0;i<X.size();i++)
		{
			A[i].second=X[i];
			A[i].first=X[i].first*X[i].first+X[i].second*X[i].second;
		}
		sort(A.begin(),A.end());
		if(A.size()<K)cout<<"No\n";
		else
		{
			cout<<"Yes\n";
			cout<<A[K-1].second.first<<" "<<A[K-1].second.second<<"\n";
		}
	}
}
            
            
            
        