結果

問題 No.3585 Make Ends Meet (Easy)
コンテスト
ユーザー GhostMFC
提出日時 2026-11-24 16:48:32
言語 C++23(gcc16)
(gcc 16.2.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc16.so -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,347 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,451 ms
コンパイル使用メモリ 356,484 KB
実行使用メモリ 9,928 KB
最終ジャッジ日時 2026-11-24 16:48:40
合計ジャッジ時間 6,338 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other AC * 10 WA * 38
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#define All(x) x.begin(),x.end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

using ll=long long;

signed main(){
    IOS

    int n,m,k;
    cin>>n>>m>>k;
    m=n*(n-1)/2-m;
    for(int sz=1;sz<=n;++sz){
        int in=sz*(sz-1)/2;
        int ou=n-sz;
        if(in+ou==m){
            if(k>1+n-sz) break;
            cout<<"Yes\n";
            for(int i=sz+1;i<=n;++i)
                cout<<i-1<<' '<<i<<'\n';
            for(int i=1;i<=sz;++i)
                for(int j=i+1;j<=sz;++j)
                    if(i!=1||j!=sz)
                        cout<<i<<' '<<j<<'\n';
            cout<<1<<' '<<n-k+1<<'\n';
            return 0;
        } else if(in+ou>m){
            cerr<<"HERE! "<<sz<<' '<<in<<' '<<ou<<'\n';
            --sz;
            if(k>1+n-sz) break;
            in=sz*(sz-1)/2;
            ou=n-sz;
            m-=in+ou;
            cout<<"Yes\n";
            for(int i=1;i<=sz;++i)
                for(int j=i+1;j<=sz;++j)
                    if(i!=1||j!=sz)
                        cout<<i<<' '<<j<<'\n';
            for(int i=sz+1;i<=n;++i)
                cout<<i-1<<' '<<i<<'\n';
            for(int i=2;i<=sz&&i-1<=k;++i)
                cout<<i<<' '<<sz+1<<'\n';
            cout<<1<<' '<<n-k+1<<'\n';
            return 0;
        }
    }
    cout<<"No\n";
}
0