結果

問題 No.3506 All Distance is Square Number
コンテスト
ユーザー ryoku
提出日時 2026-04-19 12:20:56
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 20,367 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,568 ms
コンパイル使用メモリ 299,432 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-04-19 12:21:11
合計ジャッジ時間 4,545 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 29
権限があれば一括ダウンロードができます
コンパイルメッセージ
lib/graph/base.hpp:21:7: warning: declaration of 'using static_graph<is_directed, T>::edge = struct edge<T>' changes meaning of 'edge' [-Wchanges-meaning]
lib/graph/base.hpp:21:12: note: used here to mean 'struct edge<T>'
lib/graph/base.hpp:9:8: note: declared here

ソースコード

diff #
raw source code

#line 1 "a.cpp"
#line 2 "lib/template.hpp"
#pragma GCC optimize("O3")
using namespace std;
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <climits>
#include <cassert>
#include <functional>
#include <iterator>
#include <utility>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
#include <limits>
#include <optional>
#include <variant>
#include <any>

#include <array>
#include <bit>
#include <compare>
#include <concepts>
#include <format>
#include <numbers>
#include <ranges>
#include <span>
#include <string_view>
#include <tuple>
#include <type_traits>
#include <version>
using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using i128=__int128;
template<class T>using vc=vector<T>;
template<class T>using vvc=vc<vc<T>>;
template<class T>using vvvc=vvc<vc<T>>;
#define vec(d,T,n,...) vec_##d(T,n,__VA_ARGS__)
#define vec_1(T,n,a) vector<T> n(a)
#define vec_2(T,n,a,b) vector<vector<T>> n(a,vector<T>(b))
#define vec_3(T,n,a,b,c) vector<vector<vector<T>>> n(a,vector<vector<T>>(b,vector<T>(c)))
#define vec_4(T,n,a,b,c,d) vector<vector<vector<vector<T>>>> n(a,vector<vector<vector<T>>>(b,vector<vector<T>>(c,vector<T>(d))))
#define vec_5(T,n,a,b,c,d,e) vector<vector<vector<vector<vector<T>>>>> n(a,vector<vector<vector<vector<T>>>>(b,vector<vector<vector<T>>>(c,vector<vector<T>>(d,vector<T>(e)))))
#define vec_6(T,n,a,b,c,d,e,f) vector<vector<vector<vector<vector<vector<T>>>>>> n(a,vector<vector<vector<vector<vector<T>>>>>(b,vector<vector<vector<vector<T>>>>(c,vector<vector<vector<T>>>(d,vector<vector<T>>(e,vector<T>(f))))))
#define vec_7(T,n,a,b,c,d,e,f,g) vector<vector<vector<vector<vector<vector<vector<T>>>>>>> n(a,vector<vector<vector<vector<vector<vector<T>>>>>>(b,vector<vector<vector<vector<vector<T>>>>>(c,vector<vector<vector<vector<T>>>>(d,vector<vector<vector<T>>>(e,vector<vector<T>>(f,vector<T>(g)))))))
template<class T>using smpq=priority_queue<T,vector<T>,greater<T>>;
template<class T>using bipq=priority_queue<T>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP(i,j,n) for(ll i=(j);i<(ll)(n);i++)
#define DREP(i,n,m) for(ll i=(n);i>=(m);i--)
#define drep(i,n) for(ll i=((n)-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define is insert
#define bg begin()
#define ed end()
void scan(int&a) { cin >> a; }
void scan(ll&a) { cin >> a; }
void scan(string&a) { cin >> a; }
void scan(char&a) { cin >> a; }
void scan(uint&a) { cin >> a; }
void scan(ull&a) { cin >> a; }
void scan(bool&a) { cin >> a; }
void scan(ld&a){ cin>> a;}
template<class T> void scan(vector<T>&a) { for(auto&x:a) scan(x); }
void read() {}
template<class Head, class... Tail> void read(Head&head, Tail&... tail) { scan(head); read(tail...); }
#define INT(...) int __VA_ARGS__; read(__VA_ARGS__);
#define LL(...) ll __VA_ARGS__; read(__VA_ARGS__);
#define ULL(...) ull __VA_ARGS__; read(__VA_ARGS__);
#define STR(...) string __VA_ARGS__; read(__VA_ARGS__);
#define CHR(...) char __VA_ARGS__; read(__VA_ARGS__);
#define DBL(...) double __VA_ARGS__; read(__VA_ARGS__);
#define LD(...) ld __VA_ARGS__; read(__VA_ARGS__);
#define VC(type, name, ...) vector<type> name(__VA_ARGS__); read(name);
#define VVC(type, name, size, ...) vector<vector<type>> name(size, vector<type>(__VA_ARGS__)); read(name);
template<class T>void print(T a) { cout << a; }
template<class T> void print(vector<T>a) { for(int i=0;i<(int)a.size();i++){if(i)cout<<" ";print(a[i]);}cout<<endl;}
void PRT() { cout <<endl; return ; }
template<class T> void PRT(T a) { print(a); cout <<endl; return; }
template<class Head, class... Tail> void PRT(Head head, Tail ... tail) { print(head); cout << " "; PRT(tail...); return; }
template<class T,class F>
bool chmin(T &x, F y){
    if(x>y){
        x=y;
        return true;
    }
    return false;
}
template<class T, class F>
bool chmax(T &x, F y){
    if(x<y){
        x=y;
        return true;
    }
    return false;
}
template <typename T>
T floor(T a, T b) {
  return a / b - (a % b && (a ^ b) < 0);
}
template <typename T>
T ceil(T x, T y) {
  return floor(x + y - 1, y);
}
template <typename T>
T bmod(T x, T y) {
  return x - y * floor(x, y);
}
template <typename T>
pair<T, T> divmod(T x, T y) {
  T q = floor(x, y);
  return {q, x - q * y};
}
void YesNo(bool b){
    cout<<(b?"Yes":"No")<<endl;
}
void Yes(){
    cout<<"Yes"<<endl;
}
void No(){
    cout<<"No"<<endl;
}
template<class T=ll>
T isqrt(T x){
    T F=sqrtl(x);
    while((F+1)*(F+1)<=x)F++;
    while(F*F>x)F--;
    return F;
}
template<class T>
int popcount(T n){
    return __builtin_popcountll(n);
}
template<class T,class L=ll>
L sum(vc<T>&a){
    return accumulate(all(a),L(0));
}
template<class T>
vc<T>subset(T S){
    vc<T>ans;
    for(T x=S;x>0;x=(x-1)&S)ans.pb(x);
    ans.pb(0);
    return ans;
}
template<class T>
T max(vc<T>&a){
    return *max_element(all(a));
}
template<class T>
T min(vc<T>&a){
    return *min_element(all(a));
}
vvc<int>readgraph(int n,int m,int off = -1){
    vvc<int> g(n);
    rep(i, m){
        int u,v;
        cin>>u>>v;
        u+=off,v+=off;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    return g;
}
vvc<int> readtree(int n,int off=-1){
    return readgraph(n,n-1,off);
}
template<class T,class L=ll>
vc<L> presum(vc<T> &a){
    vc<L> ret(a.size()+1);
    rep(i,a.size())ret[i+1]=ret[i]+a[i];
    return ret;
}
template<class T, class F>
vc<T> &operator+=(vc<T> &a,F b){
    for (auto&v:a)v += b;
    return a;
}
template<class T, class F>
vc<T> &operator-=(vc<T>&a,F b){
    for (auto&v:a)v-=b;
    return a;
}
template<class T, class F>
vc<T> &operator*=(vc<T>&a,F b){
    for (auto&v:a)v*=b;
    return a;
}
template<class T=ll>
constexpr T POW(T a,T b){
    T res=1;
    while(b){
        if(b&1)res*=a;
        a*=a;
        b/=2;
    }
    return res;
}
constexpr ll ten(ll a){
    return POW<ll>(10,a);
}
template<class T>
struct Compress{    
    vc<T>v;
    bool worked;
    Compress(){worked=0;}
    Compress(int n){v.reserve(n);worked=0;}
    void push(T x){
        v.push_back(x);
    }
    void work(){
        if(worked)return;
        worked=1;
        sort(all(v));
        v.erase(unique(all(v)),v.end());
    }
    int find(T x){
        work();
        auto itr=lower_bound(all(v),x);
        if((*itr)==x)return itr-v.begin();
        return -1;
    }
    int find_next(T x){
        work();
        return lower_bound(all(v),x)-v.begin();
    }
    int find_prev(T x){
        work();
        return lower_bound(all(v),x)-v.begin()-1;
    }
};
int tbit(int32_t x){return x==0?-1:31-__builtin_clz((uint32_t)x);}
int lbit(int32_t x){return x==0?-1:__builtin_ctz((uint32_t)x);}
int tbit(uint32_t x){return x==0?-1:31-__builtin_clz(x);}
int lbit(uint32_t x){return x==0?-1:__builtin_ctz(x);}
int tbit(int64_t x){return x==0?-1:63-__builtin_clzll((uint64_t)x);}
int lbit(int64_t x){return x==0?-1:__builtin_ctzll((uint64_t)x);}
int tbit(uint64_t x){return x==0?-1:63-__builtin_clzll(x);}
int lbit(uint64_t x){return x==0?-1:__builtin_ctzll(x);}
int tbit(int32_t x,int p){return p<0?-1:tbit((int32_t)(x&(p>=31?~0u:(1u<<(p+1))-1)));}
int lbit(int32_t x,int p){return p>31?-1:lbit((int32_t)(x&(~0u<<p)));}
int tbit(uint32_t x,int p){return p<0?-1:tbit((uint32_t)(x&(p>=31?~0u:(1u<<(p+1))-1)));}
int lbit(uint32_t x,int p){return p>31?-1:lbit((uint32_t)(x&(~0u<<p)));}
int tbit(int64_t x,int p){return p<0?-1:tbit((int64_t)(x&(p>=63?~0ULL:(1ULL<<(p+1))-1)));}
int lbit(int64_t x,int p){return p>63?-1:lbit((int64_t)(x&(~0ULL<<p)));}
int tbit(uint64_t x,int p){return p<0?-1:tbit((uint64_t)(x&(p>=63?~0ULL:(1ULL<<(p+1))-1)));}
int lbit(uint64_t x,int p){return p>63?-1:lbit((uint64_t)(x&(~0ULL<<p)));}
std::istream& operator>>(std::istream& is, __int128& x) {
    std::streambuf* sb = is.rdbuf();

    int c = sb->sgetc();
    while (c <= ' ') c = sb->snextc();

    bool neg = false;
    if (c == '-') {
        neg = true;
        c = sb->snextc();
    }

    unsigned __int128 v = 0;

    while ((unsigned)(c - '0') < 10) {
        v = v * 10 + (c - '0');
        c = sb->snextc();
    }

    x = neg ? -(__int128)v : (__int128)v;
    return is;
}

std::ostream& operator<<(std::ostream& os, __int128 x) {
    std::streambuf* sb = os.rdbuf();

    if (x == 0) {
        sb->sputc('0');
        return os;
    }

    char buf[40];
    int pos = 39;

    bool neg = x < 0;
    unsigned __int128 v = neg ? -(unsigned __int128)x : (unsigned __int128)x;

    while (v) {
        buf[--pos] = char('0' + (v % 10));
        v /= 10;
    }

    if (neg) buf[--pos] = '-';

    sb->sputn(buf + pos, 39 - pos);
    return os;
}
#ifdef LOCAL

template<typename T, typename U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p);
template<typename T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v);
template<typename T> std::ostream& operator<<(std::ostream& os, const std::deque<T>& dq);
template<typename T> std::ostream& operator<<(std::ostream& os, const std::list<T>& lst);
template<typename T> std::ostream& operator<<(std::ostream& os, const std::set<T>& s);
template<typename T> std::ostream& operator<<(std::ostream& os, const std::unordered_set<T>& s);
template<typename K, typename V> std::ostream& operator<<(std::ostream& os, const std::map<K, V>& m);
template<typename K, typename V> std::ostream& operator<<(std::ostream& os, const std::unordered_map<K, V>& m);
template<typename T> std::ostream& operator<<(std::ostream& os, std::stack<T> st);
template<typename T> std::ostream& operator<<(std::ostream& os, std::queue<T> q);
template<typename T, std::size_t N> std::ostream& operator<<(std::ostream& os, const std::array<T, N>& a);
template <typename T, typename Container, typename Compare>
std::ostream& operator<<(std::ostream& os, std::priority_queue<T, Container, Compare> pq);

#define dbg(...) debug_func(0, #__VA_ARGS__, __VA_ARGS__)

template <typename T>
void debug_func(int i, T name) {
  cout << endl;
}

template <typename T1, typename T2, typename... T3>
void debug_func(int i, const T1 &name, const T2 &a, const T3 &...b) {
  for ( ; name[i] != ',' && name[i] != '\0'; i++ ) cout << name[i];
  cout << ":" << a << " ";
  debug_func(i + 1, name, b...);
}
// pair
template<typename T, typename U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
    return os << "(" << p.first << ", " << p.second << ")";
}
// vector
template<typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {
    os << "[";
    for (size_t i = 0; i < v.size(); ++i) {
        if (i > 0) os << ", ";
        os << v[i];
    }
    os << "]";
    return os;
}

template<typename T>
std::ostream& operator<<(std::ostream& os, const std::deque<T>& dq) {
    os << "[";
    for (size_t i = 0; i < dq.size(); ++i) {
        if (i > 0) os << ", ";
        os << dq[i];
    }
    os << "]";
    return os;
}

template<typename T>
std::ostream& operator<<(std::ostream& os, const std::list<T>& lst) {
    os << "[";
    bool first = true;
    for (const auto& x : lst) {
        if (!first) os << ", ";
        os << x;
        first = false;
    }
    os << "]";
    return os;
}

template<typename T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& s) {
    os << "{";
    bool first = true;
    for (const auto& x : s) {
        if (!first) os << ", ";
        os << x;
        first = false;
    }
    os << "}";
    return os;
}

template<typename T>
std::ostream& operator<<(std::ostream& os, const std::unordered_set<T>& s) {
    os << "{";
    bool first = true;
    for (const auto& x : s) {
        if (!first) os << ", ";
        os << x;
        first = false;
    }
    os << "}";
    return os;
}

template<typename K, typename V>
std::ostream& operator<<(std::ostream& os, const std::map<K, V>& m) {
    os << "{";
    bool first = true;
    for (const auto& kv : m) {
        if (!first) os << ", ";
        os << kv;
        first = false;
    }
    os << "}";
    return os;
}

template<typename K, typename V>
std::ostream& operator<<(std::ostream& os, const std::unordered_map<K, V>& m) {
    os << "{";
    bool first = true;
    for (const auto& kv : m) {
        if (!first) os << ", ";
        os << kv;
        first = false;
    }
    os << "}";
    return os;
}

template<typename T>
std::ostream& operator<<(std::ostream& os, std::stack<T> st) {
    os << "[";
    bool first = true;
    while (!st.empty()) {
        if (!first) os << ", ";
        os << st.top();
        st.pop();
        first = false;
    }
    os << "]";
    return os;
}

template<typename T>
std::ostream& operator<<(std::ostream& os, std::queue<T> q) {
    os << "[";
    bool first = true;
    while (!q.empty()) {
        if (!first) os << ", ";
        os << q.front();
        q.pop();
        first = false;
    }
    os << "]";
    return os;
}

template<typename T, typename Container, typename Compare>
std::ostream& operator<<(std::ostream& os, std::priority_queue<T, Container, Compare> pq) {
    os << "[";
    while (!pq.empty()) {
        os << pq.top() << (pq.size() > 1 ? ", " : "");
        pq.pop();
    }
    return os << "]";
}
template<typename T, std::size_t N>
std::ostream& operator<<(std::ostream& os, const std::array<T, N>& a) {
    os << "[";
    for (std::size_t i = 0; i < N; ++i) {
        if (i > 0) os << ", ";
        os << a[i];
    }
    os << "]";
    return os;
}
#else
#define dbg(...) 1111
#endif
#line 3 "lib/graph/base.hpp"
struct Unweighted{
    Unweighted()=default;
    Unweighted(int){}
    operator int()const{return 1;}
};
template<class T=Unweighted>
struct edge{
    int from,to,id;
    [[no_unique_address]] T cost;
    #ifdef LOCAL
    friend ostream&operator<<(ostream&os,const edge&e){
        return os<<"{from:"<<e.from<<",to:"<<e.to<<",id:"<<e.id<<",cost:"<<e.cost<<"}";
    }
    #endif
};
template<bool is_directed,class T=Unweighted>
struct static_graph{
    constexpr static bool directed(){return is_directed;}
using edge=edge<T>;
private:
    int n,m,added=0;
    mutable bool csr_built=false,inv_built=false;
    vc<edge>_all_edges;
    mutable vc<int>csr_start;
    mutable vc<edge>csr_edge;
    mutable vc<int>inv_start;
    mutable vc<edge>inv_edge;
public:
    static_graph(int n):n(n),m(-1),csr_start(n+1){}
    static_graph(int n,int m):n(n),m(m),csr_start(n+1){_all_edges.reserve(m);}
    void add_edge(int a,int b,T cost=1,int id=-1){
        assert(0<=a&&a<n&&0<=b&&b<n);
        if(id==-1)id=(int)_all_edges.size();
        _all_edges.push_back({a,b,id,cost});
        csr_built=inv_built=false;
        if(++added==m)build();
    }
    void build()const{
        if(csr_built)return;
        csr_built=true;
        csr_start.assign(n+1,0);
        for(auto&e:_all_edges){
            csr_start[e.from+1]++;
            if constexpr(!is_directed)csr_start[e.to+1]++;
        }
        rep(i,n)csr_start[i+1]+=csr_start[i];
        csr_edge.resize(csr_start[n]);
        vc<int>now=csr_start;
        for(auto&e:_all_edges){
            csr_edge[now[e.from]++]=e;
            if constexpr(!is_directed)csr_edge[now[e.to]++]={e.to,e.from,e.id,e.cost};
        }
    }
    void build_inv()const{
        if(inv_built)return;
        inv_built=true;
        inv_start.assign(n+1,0);
        for(auto&e:_all_edges){
            inv_start[e.to+1]++;
            if constexpr(!is_directed)inv_start[e.from+1]++;
        }
        rep(i,n)inv_start[i+1]+=inv_start[i];
        inv_edge.resize(inv_start[n]);
        vc<int>now=inv_start;
        for(auto&e:_all_edges){
            inv_edge[now[e.to]++]={e.to,e.from,e.id,e.cost};
            if constexpr(!is_directed)inv_edge[now[e.from]++]=e;
        }
    }
    const vc<edge>&all_edges()const{return _all_edges;}
    int edge_size()const{return (int)_all_edges.size();}
    edge get_edge(int id)const{
        assert(0<=id&&id<edge_size());
        return _all_edges[id];
    }
    int out_deg(int u)const{assert(0<=u&&u<n);build();return csr_start[u+1]-csr_start[u];}
    int in_deg(int u)const{assert(0<=u&&u<n);build_inv();return inv_start[u+1]-inv_start[u];}
    int deg(int u)const{return out_deg(u);}
    template<class E>
    struct span{
        E*l; E* r;
        E*begin()const{return l;}
        E*end()const{return r;}
        int size()const{return r-l;}
        E&operator[](int i){return l[i];}
        const E&operator[](int i)const{return l[i];}
    };
    auto operator[](int u){
        assert(0<=u&&u<n);build();
        return span<edge>{csr_edge.data()+csr_start[u],csr_edge.data()+csr_start[u+1]};
    }
    auto operator[](int u)const{
        assert(0<=u&&u<n);build();
        return span<const edge>{csr_edge.data()+csr_start[u],csr_edge.data()+csr_start[u+1]};
    }
    auto inv(int u){
        assert(0<=u&&u<n);build_inv();
        return span<edge>{inv_edge.data()+inv_start[u],inv_edge.data()+inv_start[u+1]};
    }
    auto inv(int u)const{
        assert(0<=u&&u<n);build_inv();
        return span<const edge>{inv_edge.data()+inv_start[u],inv_edge.data()+inv_start[u+1]};
    }
    int size()const{return n;}
    template<class F>vvc<F>adj()const{
        vvc<F>res(n,vc<F>(n));
        for(auto&e:all_edges()){
            res[e.from][e.to]=e.cost;
            if(directed()==false)res[e.to][e.from]=e.cost;
        }
        return res;
    }
    void clear(){
        added=0;
        csr_built=false;
        inv_built=false;
        _all_edges.clear();_all_edges.shrink_to_fit();
        csr_start.assign(n+1,0);csr_start.shrink_to_fit();
        csr_edge.clear();csr_edge.shrink_to_fit();
        inv_start.clear();inv_start.shrink_to_fit();
        inv_edge.clear();inv_edge.shrink_to_fit();
    }
    template<class F>
    void sort(int i,F f){
        assert(0<=i&&i<n);
        build();
        sort(csr_edge.begin()+csr_start[i],csr_edge.begin()+csr_start[i+1],f);
    }
    template<class F>
    void sort_inv(int i,F f){
        assert(0<=i&&i<n);
        build_inv();
        sort(inv_edge.begin()+inv_start[i],inv_edge.begin()+inv_start[i+1],f);
    }
    template<class F>
    static_graph<is_directed,T>extract(F f)const{
        static_graph<is_directed,T>res(n);
        for(auto&e:_all_edges)if(f(e))res.add_edge(e.from,e.to,e.cost,e.id);
        return res;
    }
    template<class F>
    static_graph<1,T>reorder(F f)const{
        static_graph<1,T>res(n);
        for(auto&e:_all_edges){
            if(f(e))res.add_edge(e.from,e.to,e.cost,e.id);
            else res.add_edge(e.to,e.from,e.cost,e.id);
        }
        return res;
    }
};
#line 3 "a.cpp"
void solve(){
    INT(n);
    if(n==2){
        cout<<"1 2 1\n";
        rep(t,2)cout<<"1 1\n";
        return;
    }
    static_graph<0,int>g(n);
    rep(i,n-1){
        g.add_edge(i,i+1,2*i+1);
    }
    REP(i,2,n){
        g.add_edge(1,i,2*i);
    }
    g.build();
    PRT(g.edge_size());
    vc<edge<int>>edges(g.edge_size());
    rep(i,n)for(auto&e:g[i]){
        edges[e.id]=e;
    }
    for(auto&x:edges){
        cout<<x.from+1<<" "<<x.to+1<<" "<<x.cost<<"\n";
    }

    int S=0;
    auto Find=[&](int x,int to,int c){
        S+=c;
        for(auto&e:g[x]){
            if(e.to==to&&e.cost==c)return e.id;
        }
        assert(0);
    };
    dbg("======="s);
    rep(i,n-1){
        S=0;
        vc<int>es;
        if(i==0){es.pb(Find(0,1,1));}
        else if(i==1)es.pb(Find(1,2,4));
        else{
            for(int j=i;j>2;j--){
                
                es.pb(Find(j,j-1,(j-1)*2+1));
            }
            es.pb(Find(2,1,3));
            es.pb(Find(1,i+1,2*(i+1)));
        }
        REP(j,i+1,n){
            dbg(i,j,S);
            cout<<es.size()<<" ";rep(i,es.size())cout<<es[i]+1<<" \n"[i+1==es.size()];
            if(j!=n-1)es.pb(Find(j,j+1,2*(j+1)-1));
        }
    }
}
signed main(){
    dbg("==============="s);
    #ifdef LOCAL
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    cin.tie(0)->sync_with_stdio(0);
    cout<<fixed<<setprecision(20);
    int t=1;
    // cin >> t;
    while(t--)solve();
}
0