結果

問題 No.3585 Make Ends Meet (Easy)
コンテスト
ユーザー t98slider
提出日時 2026-07-10 22:46:19
言語 C++23
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,025 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,048 ms
コンパイル使用メモリ 336,072 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2026-07-10 22:46:25
合計ジャッジ時間 4,312 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other AC * 17 WA * 31
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    vector<pair<int,int>> ans;
    array<array<bool,100>,100> B{};
    for(int i = 0; i <= k; i++){
        for(int j = i + 2; j <= k; j++){
            B[i][j] = B[j][i] = true;
            ans.emplace_back(i + 1, j + 1);
        }
    }
    for(int i = k + 1; i < n; i++){
        for(int j = 3; j <= k; j++){
            B[j][i] = B[i][j] = true;
            ans.emplace_back(j + 1, i + 1);
        }
    }
    if(m < ans.size()){
        cout << "No" << endl;
        return 0;
    }
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            if(!B[i][j]) ans.emplace_back(i + 1, j + 1);
        }
    }
    if(ans.size() < m){
        cout << "No" << endl;
    }else{
        cout << "Yes\n";
        for(int i = 0; i < m; i++){
            auto [u, v] = ans[i];
            cout << u << ' ' << v << '\n';
        }
    }
}
0