結果

問題 No.1519 Diversity
ユーザー umezoumezo
提出日時 2021-05-28 22:33:50
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 671 bytes
コンパイル時間 2,038 ms
コンパイル使用メモリ 202,076 KB
実行使用メモリ 4,572 KB
最終ジャッジ日時 2023-08-07 06:25:34
合計ジャッジ時間 3,090 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

vector<int> G[500];

int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int n;
  cin>>n;
  int k=0;
  for(int i=1;i<=500;i++){
    if(2*n-2-i*(i+1)/2>=n-i) k=i;
  }
  G[0].push_back(1);
  rep(i,k) G[1].push_back(2+i);
  int now=k+2;
  int h=1,b=max(1,k-2);
  while(now<=n){
    h++;
    rep(i,b){
      G[h].push_back(now);
      now++;
    }
    b=max(1,b-1);
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<(int)G[i+1].size();j++){
      cout<<G[i][0]<<" "<<G[i+1][j]<<endl;
    }
  }

  return 0;
}
0