結果

問題 No.1519 Diversity
ユーザー shiomusubi496shiomusubi496
提出日時 2021-05-28 20:35:13
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 612 bytes
コンパイル時間 2,156 ms
コンパイル使用メモリ 201,620 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 22:56:00
合計ジャッジ時間 3,873 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 29 ms
5,376 KB
testcase_04 AC 63 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 85 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 11 ms
5,376 KB
testcase_09 AC 31 ms
5,376 KB
testcase_10 AC 58 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 83 ms
5,376 KB
testcase_13 AC 84 ms
5,376 KB
testcase_14 AC 84 ms
5,376 KB
testcase_15 AC 87 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    int N; cin>>N;
    vector<pair<int,int>> E;
    vector<int> A(N);
    for(int i=1;i<N;i++){
        vector<vector<int>> B(N);
        for(int j=0;j<i;j++) B[A[j]].push_back(j);
        int j=0;
        for(;j<i && B[j].size()<=1;j++);
        int cnt=0;
        for(;j<i;j++){
            if(B[j].size()>=1){
                E.push_back({i,B[j][0]});
                A[B[j][0]]++;
                cnt++;
            }
        }
        A[i]=cnt;
    }
    cout<<E.size()<<endl;
    for(auto[a,b]:E)cout<<a+1<<' '<<b+1<<endl;
}
0