結果

問題 No.1519 Diversity
ユーザー oxyshoweroxyshower
提出日時 2021-05-30 12:11:28
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 89 ms / 2,000 ms
コード長 1,261 bytes
コンパイル時間 1,567 ms
コンパイル使用メモリ 171,592 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-08 15:01:00
合計ジャッジ時間 3,431 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

#ifdef _DEBUG
#include "_DEBUG.hpp"
#endif
#define int long long
const long long inf = 2e18;
const int mod = 1e9 + 7;

template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (T &in : v) is >> in;
  return is;
}

template <class T>
vector<T> make_vec(size_t a) {
  return vector<T>(a);
}

template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template <class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
  t = v;
}

template <class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v) {
  for (auto &e : t) fill(e, v);
}

signed main() {

  int n;
  cin >> n;

  vector<pair<int, int>> ans;
  vector<bool> used(n, false);
  vector<int> cnt(n, 0);
  int low = n - 1;
  for (int i = 0; i < n; i++) {
    used[i] = true;
    for (int j = 0; j < n; j++) {
      if (cnt[i] >= low) break;
      if (!used[j]) {
        ans.push_back({i + 1, j + 1});
        cnt[i]++;
        cnt[j]++;
      }
    }
    low--;
  }

  cout << ans.size() << endl;
  for (auto p : ans) {
    cout << p.first << " " << p.second << endl;
  }
  
  return 0;
}
0