結果

問題 No.1519 Diversity
ユーザー milanis48663220
提出日時 2021-05-28 21:54:22
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 1,476 bytes
コンパイル時間 1,260 ms
コンパイル使用メモリ 118,252 KB
最終ジャッジ日時 2025-01-21 20:01:49
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

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;
}
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0