QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#417734 | #3276. 出题高手 | K8He | 0 | 601ms | 15392kb | C++20 | 2.5kb | 2024-05-22 21:26:35 | 2024-05-22 21:26:37 |
Judging History
answer
#include <bits/stdc++.h>
#define _for(i, a, b) for (int i = a; i <= b; ++i)
#define for_(i, a, b) for (int i = a; i >= b; --i)
#define far(i, vec) for (auto i : vec)
#define bdmd int mid = (l + r) >> 1
typedef long double ldb;
typedef long long ll;
typedef double db;
typedef std::pair <int, int> pii;
typedef std::pair <ll, ll> pll;
const int N = 1e5 + 10, P = 998244353;
namespace IO {
int rnt () {
int x = 0, w = 1; char c = getchar ();
while (!isdigit (c)) { if (c == '-') w = -1; c = getchar (); }
while (isdigit (c)) x = (x << 3) + (x << 1) + (c ^ 48), c = getchar ();
return x * w;
}
}
namespace SEGMENT_TREE {
class SegmentTree {
private:
int max[N << 2];
#define ls(p) (p << 1)
#define rs(p) (p << 1 | 1)
#define _ls(p) (p << 1), l, mid
#define _rs(p) (p << 1 | 1), mid + 1, r
void PushUp (int p) { max[p] = std::max (max[ls (p)], max[rs (p)]); return; }
public:
void UpdP (int p, int l, int r, int x, int val) {
max[p] = std::max (max[p], val);
if (l != r) {
bdmd;
if (x <= mid) UpdP (_ls (p), x, val);
else UpdP (_rs (p), x, val);
}
return;
}
int QueR (int p, int l, int r, int le, int ri) {
if (ri < l || r < le) return 0;
if (le <= l && r <= ri) return max[p];
else {
bdmd;
int ansl = QueR (_ls (p), le, ri);
int ansr = QueR (_rs (p), le, ri);
return std::max (ansl, ansr);
}
}
};
}
namespace SOLVE {
using namespace IO;
class Frac {
public:
int a, b;
Frac () = default;
void sim () {
int g = std::__gcd (a, b);
if (g) a /= g, b /= g;
return;
}
Frac (int a, int b) : a (a), b (b) { sim (); }
friend bool operator < (Frac a, Frac b) {
return 1ll * a.a * b.b < 1ll * b.a * a.b;
}
ldb operator () () { return 1.0l * a / b; }
ldb operator () () const { return 1.0l * a / b; }
};
int n, a[N], sum[N], q;
SEGMENT_TREE::SegmentTree tr[10];
void In () {
n = rnt ();
_for (i, 1, n) {
a[i] = rnt ();
sum[i] = sum[i - 1] + a[i];
}
return;
}
void Solve () {
_for (k, 0, 9) _for (i, 1, n - k)
tr[k].UpdP (1, 1, n, i, std::abs (sum[i + k] - sum[i - 1]));
return;
}
void Out () {
q = rnt ();
_for (i, 1, q) {
int l = rnt (), r = rnt ();
Frac ans (0, 1);
_for (k, 0, 9) {
if (l + k > r) break;
int x = tr[k].QueR (1, 1, n, l, r - k);
ans = std::max (ans, Frac (x * x, k + 1));
}
printf ("%d %d\n", ans.a, ans.b);
}
return;
}
}
int main () {
#ifndef ONLINE_JUDGE
freopen ("data.in", "r", stdin);
// freopen ("data.out", "w", stdout);
#endif
SOLVE::In ();
SOLVE::Solve ();
SOLVE::Out ();
return 0;
} /*
*/
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 101ms
memory: 3908kb
input:
2000 -113 314 -664 697 211 -199 -38 -190 8 -661 910 -811 -113 942 77 433 -261 -368 129 -525 968 -608 -21 38 -562 438 -935 -228 220 333 985 -430 916 586 764 476 794 664 383 503 206 -60 380 -130 -988 -904 -996 -304 -286 31 114 119 850 -942 714 -369 -842 250 -192 -462 -727 -427 -602 126 231 718 121 559...
output:
4780232 1 14638276 7 1185921 1 2307361 1 6310144 3 12545764 5 5094049 2 23068809 8 23068809 8 12545764 5 1444908 1 5424241 3 1083603 1 2140369 1 2752281 2 3095072 1 3003289 2 4959529 2 2550409 2 4780232 1 7198489 3 8543929 4 13830961 9 5094049 2 12545764 5 8543929 4 6466849 2 19158129 7 4372281 2 12...
result:
wrong answer 1st numbers differ - expected: '54826875', found: '4780232'
Subtask #2:
score: 0
Wrong Answer
Test #6:
score: 0
Wrong Answer
time: 31ms
memory: 15268kb
input:
100000 754 792 -680 426 425 347 481 -690 530 378 73 -907 -431 45 -530 -552 440 -890 -15 712 695 -679 -310 13 718 805 193 -291 -877 -74 -355 511 -679 -395 166 -710 -657 -19 874 26 832 507 854 -289 700 -404 472 -302 -977 8 -698 40 766 705 369 838 700 -964 552 -535 -75 -608 -181 -503 468 447 772 904 -2...
output:
50282281 8
result:
wrong answer 1st numbers differ - expected: '466344025', found: '50282281'
Subtask #3:
score: 0
Wrong Answer
Test #11:
score: 0
Wrong Answer
time: 3ms
memory: 4524kb
input:
500000 794 -75 -596 -322 -945 -908 -609 -164 488 626 -877 -710 140 -120 -475 -837 738 669 634 -643 -682 667 816 -785 -608 -836 -860 -932 242 70 -620 268 -121 288 209 -392 732 750 558 -480 565 327 -217 -891 767 211 -690 -66 813 -889 952 615 432 19 411 800 678 718 522 422 940 -510 -544 449 -357 640 40...
output:
0 1 0 1 0 1 0 1 16168441 5 44395569 10 44395569 10 0 1 0 1 44395569 10 44395569 10 0 1 44395569 10 0 1 0 1 0 1 0 1 0 1 44395569 10 18398178 5 44395569 10 0 1 0 1 25725184 7 0 1 44395569 10 0 1 44395569 10 0 1 16168441 5 18398178 5 0 1 0 1 0 1 0 1 0 1 0 1 0 1 44395569 10 44395569 10 0 1 44395569 10 0...
result:
wrong answer 1st numbers differ - expected: '1878442281', found: '0'
Subtask #4:
score: 0
Wrong Answer
Test #16:
score: 0
Wrong Answer
time: 49ms
memory: 14836kb
input:
100000 -496 -233 354 -632 -196 177 -878 -255 -19 -636 685 -70 101 -975 -406 -988 -965 -205 563 -766 763 511 -116 -746 -129 14 106 928 -457 -257 -283 226 3 899 -359 -792 615 490 -57 986 -243 624 -239 931 -555 -821 -72 -611 -380 -397 248 -132 956 -195 -322 -231 319 -214 837 -379 -931 -301 -4 -673 280 ...
output:
36784225 8 10460738 3 7116245 2 6838225 2 10885778 3 27836176 7 4578338 1 7334450 3 3802183 1 2411809 2 2835045 1 13712209 5 18498601 6 3256352 1 4023045 2 17546888 5 23396569 6 21762225 7 4012009 3 2661336 1 23590449 7 29041321 9 24830289 8 3672245 1 6120676 3 7573504 3 14891881 5 857476 1 14289858...
result:
wrong answer 1st numbers differ - expected: '1352474176', found: '36784225'
Subtask #5:
score: 0
Wrong Answer
Test #31:
score: 0
Wrong Answer
time: 601ms
memory: 15392kb
input:
100000 139 -485 -497 -818 254 169 -560 22 377 -67 -243 -75 743 -788 -676 -26 -775 371 576 -303 54 733 422 800 445 687 479 -16 -288 259 783 -586 912 616 439 -416 676 -555 172 659 501 -868 337 22 -60 260 603 -982 -149 466 769 -595 -117 949 -544 904 753 20 776 175 -888 937 -792 -647 -615 59 -298 452 -6...
output:
10975969 2 3916125 1 4343056 1 23049601 8 19713600 7 22024249 6 12845056 5 6620329 2 3775805 1 7868025 4 13823282 5 23425600 7 3354050 1 48818169 10 16370116 5 44129449 10 3027600 1 10975969 2 2958400 1 6786025 2 2683044 1 3323047 1 31888609 9 24088464 7 19927296 7 7840000 3 28547649 7 6507601 4 278...
result:
wrong answer 1st numbers differ - expected: '401594700', found: '10975969'