QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#270815 | #5154. ETA | ckiseki# | WA | 2ms | 3596kb | C++20 | 1.5kb | 2023-12-01 15:09:38 | 2023-12-01 15:09:39 |
Judging History
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