結果
| 問題 | No.2493 K-th in L2 with L1 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-02-27 11:08:34 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,847 bytes |
| 記録 | |
| コンパイル時間 | 6,463 ms |
| コンパイル使用メモリ | 382,592 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2026-02-27 11:08:41 |
| 合計ジャッジ時間 | 6,809 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 4 |
コンパイルメッセージ
main.cpp: In function 'bool P(ll, ll)':
main.cpp:4:61: warning: 'i' may be used uninitialized [-Wmaybe-uninitialized]
4 | #define REP(i, x, limit) for (long long i = (long long)x; i <= (long long)limit; i++)
| ^
main.cpp:56:13: note: in expansion of macro 'REP'
56 | REP(i,i,d){
| ^~~
main.cpp:56:17: note: 'i' was declared here
56 | REP(i,i,d){
| ^
main.cpp:4:41: note: in definition of macro 'REP'
4 | #define REP(i, x, limit) for (long long i = (long long)x; i <= (long long)limit; i++)
| ^
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, x, limit) for (long long i = (long long)x; i < (long long)limit; i++)
#define REP(i, x, limit) for (long long i = (long long)x; i <= (long long)limit; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define el '\n'
#define spa " "
#define Yes cout << "Yes" << el
#define No cout << "No" << el
#define YES cout << "YES" << el
#define NO cout << "NO" << el
#define eps (1e-10)
#define Equals(a,b) (fabs((a) - (b)) < eps )
#define debug(x) cerr << #x << " = " << x << el
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;
using vb = vector<bool>;
const double pi = 3.141592653589793238;
const int inf = 1073741823;
const ll infl = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
const ll MOD = 998244353;
#include<atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using vm = vector<mint>;
bool P(ll d,ll k){
if(d==0){
if(k==1){
Yes;
cout<<0<<spa<<0<<el;
return true;
}
else{
return false;
}
}
map<ll,ll> mp;
REP(i,1,d){
mp[i*i+(d-i)*(d-i)]++;
}
ll cnt=0;
for(auto [x,y]:mp){
cnt+=y*4;
if(cnt>=k){
Yes;
REP(i,i,d){
if(i*i+(d-i)*(d-i)==x){
cout<<i<<spa<<d-i<<el;
return true;
}
}
return true;
}
}
return false;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll q;cin>>q;
while(q--){
ll d,k;cin>>d>>k;
if(!P(d,k)) No;
}
}