QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#270814#5154. ETAckiseki#WA 1ms3560kbC++201.5kb2023-12-01 15:08:582023-12-01 15:08:58

Judging History

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

  • [2023-12-01 15:08:58]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3560kb
  • [2023-12-01 15:08:58]
  • 提交

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);
    };
    add_edge(0, 1);
    int cur = n - 1;
    int last = 1;
    for (int i = 2; i < n; i++) {
      if (x - cur >= n - i) {
        cur += n - i;
        add_edge(last, i);
        last = i;
      } else {
        add_edge(last, i);
      }
    }

    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: 1ms
memory: 3560kb

input:

1/2

output:

2 1
1 2

result:

ok 

Test #2:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

1/3

output:

impossible

result:

ok 

Test #3:

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

input:

7/4

output:

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

result:

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