結果

問題 No.1519 Diversity
ユーザー milanis48663220milanis48663220
提出日時 2021-05-28 21:54:22
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 1,476 bytes
コンパイル時間 1,032 ms
コンパイル使用メモリ 120,548 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-07 05:53:20
合計ジャッジ時間 2,853 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 30 ms
4,380 KB
testcase_04 AC 65 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 86 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 12 ms
4,380 KB
testcase_09 AC 31 ms
4,376 KB
testcase_10 AC 60 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 80 ms
4,380 KB
testcase_13 AC 87 ms
4,380 KB
testcase_14 AC 87 ms
4,380 KB
testcase_15 AC 85 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int n; cin >> n;
    vector<vector<int>> g(n);
    for(int j = 1; j < n; j++){
        g[0].push_back(j);
        g[j].push_back(0);
    }
    for(int i = 1; i < n; i++){
        // if(g[i-1].size() == 2) break;
        int pre = g[i-1].size();
        int cur = i+1;
        while(g[i].size()+1 < g[i-1].size()){
            // cout << i << ' ' << i+j+1 << endl;
            g[i].push_back(cur);
            g[cur].push_back(i);
            cur++;
        }
        // cout << g[i].size() << endl;
    }
    int m = 0;
    for(int i = 0; i < n; i++) m += g[i].size();
    cout << m/2 << endl;
    for(int i = 0; i < n; i++) {
        for(int j : g[i]) {
            if(i < j) cout << i+1 << ' ' << j+1 << endl;
        }
    }
}
0