QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#233772 | #2788. Horses | Camillus# | 17 | 1ms | 3956kb | C++20 | 1.2kb | 2023-10-31 22:34:25 | 2024-07-04 02:22:05 |
Judging History
answer
#include "horses.h"
#include "bits/stdc++.h"
using ll = long long;
using namespace std;
struct mint {
static constexpr int mod = 1'000'000'007;
int data = 0;
mint() = default;
mint(int data) : data(data) {}
mint operator+(const mint &other) const {
int res = data + other.data;
if (res >= mod) {
res -= mod;
}
return res;
}
mint operator-(const mint &other) const {
int res = data + mod - other.data;
if (res >= mod) {
res -= mod;
}
return res;
}
mint operator*(const mint &other) const {
return mint(1ll * data * other.data % mod);
}
};
int n;
vector<mint> x;
vector<mint> y;
int calc() {
vector<mint> dp(n);
dp[n - 1] = x[n - 1] * y[n - 1];
for (int i = n - 2; i >= 0; i--) {
mint cur = x[i] * y[i];
mint next = x[i] * dp[i + 1];
if (cur.data > next.data) {
dp[i] = cur;
} else {
dp[i] = next;
}
}
return dp[0].data;
}
int init(int N, int X[], int Y[]) {
n = N;
x.resize(n);
y.resize(n);
for (int i = 0; i < n; i++) {
x[i] = X[i];
y[i] = Y[i];
}
return calc();
}
int updateX(int pos, int val) {
x[pos] = val;
return calc();
}
int updateY(int pos, int val) {
y[pos] = val;
return calc();
}
詳細信息
Subtask #1:
score: 17
Accepted
Test #1:
score: 17
Accepted
time: 0ms
memory: 3764kb
input:
1 2 3 0
output:
6
result:
ok single line: '6'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
10 2 1 1 5 2 1 1 10 5 1 3 5 7 9 4 1 4 10 10 9 0
output:
10000
result:
ok single line: '10000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
10 10 10 10 1 1 1 1 1 1 1 2 3 4 2 7 6 5 4 3 2 0
output:
7000
result:
ok single line: '7000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3760kb
input:
10 9 1 1 1 1 1 1 1 1 2 4 1 1 1 1 1 1 1 1 2 0
output:
36
result:
ok single line: '36'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3768kb
input:
10 1 1 1 1 1 1 1 1 1 1 1 2 3 4 5 6 7 8 9 10 0
output:
10
result:
ok single line: '10'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3748kb
input:
10 1 1 1 1 1 1 1 1 1 1 10 9 8 7 6 5 4 3 2 1 0
output:
10
result:
ok single line: '10'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
10 10 10 10 1 1 1 1 1 1 1 10 10 2 3 4 5 6 7 8 9 0
output:
9000
result:
ok single line: '9000'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3956kb
input:
10 10 10 10 1 1 1 1 1 1 1 10 10 9 8 7 6 5 4 3 2 0
output:
9000
result:
ok single line: '9000'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
10 1 1 1 1 2 2 1 1 1 1 8 8 8 8 1 1 2 2 2 2 0
output:
8
result:
ok single line: '8'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
10 1 1 1 1 1 1 1 1 1 1 1 2 3 4 5 9 8 7 6 1 0
output:
9
result:
ok single line: '9'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3772kb
input:
2 2 5 9 7 0
output:
70
result:
ok single line: '70'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
1 1 1 0
output:
1
result:
ok single line: '1'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
7 7 1 1 6 2 3 2 7 6 5 4 3 7 1 0
output:
1764
result:
ok single line: '1764'
Test #14:
score: 0
Accepted
time: 0ms
memory: 3832kb
input:
1 10 10 0
output:
100
result:
ok single line: '100'
Test #15:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
2 1 4 7 2 0
output:
8
result:
ok single line: '8'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3956kb
input:
10 1 10 1 10 1 1 10 1 1 1 7 3 10 10 4 10 1 4 5 10 0
output:
10000
result:
ok single line: '10000'
Test #17:
score: 0
Accepted
time: 1ms
memory: 3728kb
input:
6 1 1 1 1 1 1 1 1 1 1 1 1 0
output:
1
result:
ok single line: '1'
Test #18:
score: 0
Accepted
time: 0ms
memory: 3828kb
input:
4 1 2 4 8 8 4 2 1 0
output:
64
result:
ok single line: '64'
Test #19:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
6 1 2 2 3 1 1 7 1 1 2 1 1 0
output:
24
result:
ok single line: '24'
Test #20:
score: 0
Accepted
time: 0ms
memory: 3828kb
input:
10 2 1 1 5 2 1 1 10 5 1 3 5 7 9 4 1 4 10 7 9 0
output:
9000
result:
ok single line: '9000'
Subtask #2:
score: 0
Wrong Answer
Dependency #1:
100%
Accepted
Test #21:
score: 0
Wrong Answer
time: 0ms
memory: 3828kb
input:
10 10 10 10 10 10 10 1 1 1 1 1 1 1 1 9 5 4 7 3 2 5 1 5 1 2 5 123456789 1 5 1 1 8 987654321 1 9 777777777
output:
7000000 900000 678813585 678813585 862817290 294225928
result:
wrong answer 5th lines differ - expected: '294225928', found: '862817290'
Subtask #3:
score: 0
Time Limit Exceeded
Test #33:
score: 0
Time Limit Exceeded
input:
500000 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2...
output:
967631222 867564495 867564495 867564495 867564495 867564495 795463654 885679347 625612163 625612163 625612163 616649396 616649396 616649396 616649396 616649396 929301038 929301038 929301038 929301038 815547130 875189947 875189947 875189947 875189947 875189947 581166788 581166788 581166788 228315851 ...
result:
Subtask #4:
score: 0
Skipped
Dependency #2:
0%
Subtask #5:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%