結果

問題 No.1519 Diversity
コンテスト
ユーザー oxyshower
提出日時 2021-05-30 12:03:03
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,302 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 983 ms
コンパイル使用メモリ 189,844 KB
実行使用メモリ 7,976 KB
最終ジャッジ日時 2026-05-08 23:11:57
合計ジャッジ時間 3,964 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 3 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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;
    int pre = cnt[i];
    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]++;
      }
    }
    if (pre != cnt[i]) low--;
  }

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