QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#518678 | #9141. Array Spread | ucup-team3215 | WA | 1ms | 3844kb | C++20 | 1.7kb | 2024-08-14 00:32:31 | 2024-08-14 00:32:31 |
Judging History
answer
#include <algorithm>
#include <array>
#include <cstdint>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
int main() {
cin.tie(0)->sync_with_stdio(0);
for (int tc = (cin >> tc, tc); tc--; ) {
int n; cin >> n >> n;
vector<int> pts;
vector<array<int, 2>> v(n);
for (auto& [l, r]: v) cin >> l >> r, pts.insert(pts.end(), {--l, r});
sort(pts.begin(), pts.end());
pts.erase(unique(pts.begin(), pts.end()), pts.end());
for (auto& v: v) for (auto& v: v) v = lower_bound(pts.begin(), pts.end(), v) - pts.begin();
vector<int> mi, ma;
auto check = [&](int w0, int w1) {
mi.assign(pts.size() + 1, 0);
ma.assign(pts.size() + 1, 1 << 30);
ma[0] = 0;
for (int _ = mi.size(); _--; ) {
for (auto [l, r]: v) {
mi[r] = max(mi[r], mi[l] + w0);
ma[r] = min(ma[r], ma[l] + w1);
mi[l] = max(mi[l], mi[r] - w1);
ma[l] = min(ma[l], ma[r] - w0);
}
for (int i = 1; i < mi.size(); ++i) mi[i] = max(mi[i], mi[i - 1]);
for (int i = mi.size() - 1; i--; ) ma[i] = min(ma[i], ma[i + 1]);
for (int i = mi.size(); i--; ) if (mi[i] > ma[i]) return 0;
}
return 1;
};
vector<array<int, 2>> u;
for (int q = 1; q <= n; ++q)
for (int p = q; p <= n; ++p) if (gcd(p, q) == 1) u.push_back({p, q});
sort(u.begin(), u.end(), [](auto& a, auto& b) { return a[0] * b[1] < a[1] * b[0]; });
int l = -1, r = u.size() - 1;
while (r > l + 1) {
int m = (l + r) / 2;
(check(u[m][1], u[m][0])? r: l) = m;
}
int64_t p = u[r][0], q = u[r][1];
while (p % q) p += 998244353;
cout << p / q << '\n';
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3844kb
input:
3 3 3 1 3 2 3 1 2 12 6 2 3 5 7 1 9 4 8 1 2 7 11 4 5 3 4 2 3 1 2 4 4 1 1
output:
1 2 499122178
result:
ok 3 number(s): "1 2 499122178"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3688kb
input:
2000 1000000000 1 259923446 367011266 1000000000 1 882434225 971573327 1000000000 1 41585677 470369580 1000000000 1 371902212 947250194 1000000000 1 787209148 924205796 1000000000 1 259074809 960876164 1000000000 1 148079314 188254573 1000000000 1 940091047 948318624 1000000000 1 40636497 743979446 ...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok 2000 numbers
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 3584kb
input:
1000 1000000000 5 575330909 661595447 708422488 913945134 658050911 930246647 786571892 904549453 851755566 969150871 1000000000 2 198072104 844159589 8876188 644559580 1000000000 2 740802634 976972118 783909534 898449184 1000000000 2 871819537 941611957 465883854 640988372 1000000000 1 99458969 462...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
wrong answer 146th numbers differ - expected: '2', found: '1'