QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#270820#5154. ETAckiseki#WA 2ms3948kbC++201.5kb2023-12-01 15:22:342023-12-01 15:22:34

Judging History

你现在查看的是最新测评结果

  • [2023-12-01 15:22:34]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3948kb
  • [2023-12-01 15:22:34]
  • 提交

answer

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

#define all(x) begin(x), end(x)
#ifdef CKISEKI
#define safe cerr << __PRETTY_FUNCTION__ << " line " << __LINE__ << " safe\n"
#define debug(a...) debug_(#a, a)
#define orange(a...) orange_(#a, a)
#include <experimental/iterator>
void debug_(auto s, auto ...a) {
  cerr << "\e[1;32m(" << s << ") = (";
  int f = 0;
  (..., (cerr << (f++ ? ", " : "") << a));
  cerr << ")\e[0m\n";
}
void orange_(auto s, auto L, auto R) {
  cerr << "\e[1;33m[ " << s << " ] = [ ";
  using namespace experimental;
  copy(L, R, make_ostream_joiner(cerr, ", "));
  cerr << " ]\e[0m\n";
}
#else
#define safe ((void)0)
#define debug(...) safe
#define orange(...) safe
#endif

int main() {
  // cin.tie(nullptr)->sync_with_stdio(false);
  int a, b;
  scanf("%d/%d", &a, &b);

  for (int n = 2; n <= 1000000; n++) {
    if (n % b != 0) continue;

    int64_t x = 1LL * a * (n / b);
    int64_t mx = 1LL * n * (n - 1) / 2;
    if (x < n - 1) continue;
    if (x > mx) continue;

    vector<pair<int,int>> edge;
    const auto add_edge = [&](int x, int y) {
      edge.emplace_back(x, y);
    };

    int64_t cur = n - 1;

    int last = 0;

    for (int i = 1; i < n; i++) {
      if (x - cur >= n - i) {
        cur += n - i;
        add_edge(last, i);
        last = i;
      } else {
        add_edge(last, i);
      }
    }
    debug(x, cur);

    cout << n << ' ' << edge.size() << '\n';
    for (auto [x, y] : edge)
      cout << x + 1 << ' ' << y + 1 << '\n';

    return 0;
  }

  cout << "impossible\n";

  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3684kb

input:

1/2

output:

2 1
1 2

result:

ok 

Test #2:

score: 0
Accepted
time: 2ms
memory: 3948kb

input:

1/3

output:

impossible

result:

ok 

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3756kb

input:

7/4

output:

8 7
1 2
2 3
2 4
2 5
2 6
2 7
2 8

result:

FAIL Wrong average distance, got 13/8, wanted 7/4