QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#270815#5154. ETAckiseki#WA 2ms3596kbC++201.5kb2023-12-01 15:09:382023-12-01 15:09:39

Judging History

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

  • [2023-12-01 15:09:39]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3596kb
  • [2023-12-01 15:09:38]
  • 提交

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);
    int64_t 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;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3436kb

input:

1/2

output:

2 1
1 2

result:

ok 

Test #2:

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

input:

1/3

output:

impossible

result:

ok 

Test #3:

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

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