結果

問題 No.2567 A_1 > A_2 > ... > A_N
ユーザー shin3110shin3110
提出日時 2023-12-02 16:43:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,615 bytes
コンパイル時間 4,036 ms
コンパイル使用メモリ 231,512 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-12-02 16:43:18
合計ジャッジ時間 6,576 ms
ジャッジサーバーID
(参考情報)
judge13 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 144 ms
6,676 KB
testcase_07 AC 145 ms
6,676 KB
testcase_08 AC 147 ms
6,676 KB
testcase_09 AC 145 ms
6,676 KB
testcase_10 AC 144 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2 ms
6,676 KB
testcase_15 WA -
testcase_16 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

/*

              ∧∧∩ 
             ( ゚∀゚)/ キタ━━━━━━(゚∀゚)━━━━━━!!!!  
            ⊂   ノ  ゆっくり見てってね!!!!!!!!
             (つ ノ
    o          (ノ
     \      ☆
             |      o
          (⌒ ⌒ヽ   /     ☆
    \  (´⌒  ⌒  ⌒ヾ   /
      ('⌒ ; ⌒   ::⌒  )
     (´     )     ::: ) /
  ☆─ (´⌒;:    ::⌒`) :;  )

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


#define elif else if
#define rep(i, s, n) for (int i=s; i<n; i++)
#define all(a) a.begin(), a.end()
// xを2進数にした際にi桁目が0か1か
#define bit(x,i)((x>>i)&1)
typedef long long ll;
typedef long double ld;

ld pi = 3.14159265358979;

inline void scan(){}
template<class Head,class... Tail>
inline void scan(Head&head,Tail&... tail){std::cin>>head;scan(tail...);}
 
// print(a, b, c) => cout << a << ' ' << b << ' ' << c << endl;
inline void print(){}
template<class Head,class... Tail>
inline void print(Head&head,Tail&... tail){std::cout<<head<<" ";print(tail...);cout<<endl;}

// bool型に対して"Yes", "No" を出力する
bool printb(bool f) {if (f) cout << "Yes\n";else cout << "No\n";return f;}

//vectorのcout,cin
template<typename T>
std::istream &operator>>(std::istream&is,std::vector<T>&v){for(T &in:v){is>>in;}return is;}
template<typename T>
std::ostream &operator<<(std::ostream&os,const std::vector<T>&v){for(auto it=std::begin(v);it!=std::end(v);){os<<*it<<((++it)!=std::end(v)?" ":"");}return os;}

// 2地点の距離(long double)
long double coor_dist(long double xi, long double yi, long double xj, long double yj) {
    return sqrt(abs((xi - xj) * (xi - xj)) + abs((yi - yj) * (yi - yj)));
}

// 回文かどうかの判定 
bool iskaibun(string s){ll k = s.size();rep(i,0,k/2){if(s[i]!=s[k-1-i]){return false;}}return true;}

template<class T> void chmax(T& a, T b) { if (a < b) a = b; }
template<class T> void chmin(T& a, T b) { if (a > b) a = b; }



#define mod 998244353
using mint = modint998244353;
int op(int a, int b) {return max(a, b);}
int e() {return 0;}
int mapping(int f, int x) {return (f == 1e9 ? x : f);}
int composition(int f, int g) {return (f == 1e9 ? g : f);}
int id() {return 1e9;}


signed main() {
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    ios::sync_with_stdio(false);
    int t; cin >> t;
    
    ll n;
    auto f = [&](auto&& f, int idx, ll m, ll back) -> ll {
        ll sub = (n-idx)*(n-1-idx)/2;
        ll l = back+1, r = 1e18;
        if(l+1 == r) {
            if(r + sub + r*(n-idx-1) == m) l = r;
        }
        while(l+1 < r) {
            ll now = (l+r)/2;
            if(now + sub + now*(n-idx-1) > m) r = now;
            else l = now;
        }
        //cout << "LR: " << l << ' ' << r << endl;
        return l;
    };

    while(t--) {
        ll x; cin >> n >> x;
        ll sum = n*(n+1)/2;
        if(sum > x) {
            cout << -1 << endl;
            continue;
        }
        ll back = 0;
        vector<ll> ans;
        rep(i, 0, n) {
            ll num = f(f, i, x, back);
            ans.push_back(num);
            x -= num;
            back = num;
        }
        reverse(all(ans));
        cout << ans << endl;
    }
}
0