QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#563385 | #8527. Power Divisions | ucup-team3931# | WA | 5ms | 15572kb | C++14 | 1.5kb | 2024-09-14 10:48:12 | 2024-09-14 10:48:13 |
Judging History
answer
#include <bits/stdc++.h>
#define pb emplace_back
#define fst first
#define scd second
#define mkp make_pair
#define mems(a, x) memset((a), (x), sizeof(a))
using namespace std;
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
typedef long double ldb;
typedef pair<ll, ll> pii;
const int maxn = 1000100;
const ll mod = 1000000007, P = 998244353123456789;
ll n, a[maxn], f[maxn], pw[maxn];
void cdq(int l, int r) {
if (l == r) {
f[l] = (f[l] + f[l - 1]) % mod;
return;
}
int mid = (l + r) >> 1;
cdq(l, mid);
map<ll, ll> mp;
ll x = 0, y = 0;
for (int i = mid; i >= l; --i) {
x = (x + pw[a[i]]) % P;
mp[x] = (mp[x] + f[i - 1]) % mod;
}
x = 0;
for (int i = mid + 1; i <= r; ++i) {
x = (x + pw[a[i]]) % P;
y = max(y, a[i]);
f[i] = (f[i] + mp[(pw[y + 1] - x + P) % P]) % mod;
}
mp.clear();
x = y = 0;
for (int i = mid; i >= l; --i) {
x = (x + pw[a[i]]) % P;
y = max(y, a[i]);
if (x != pw[y]) {
mp[(pw[y + 1] - x + P) % P] = (mp[(pw[y + 1] - x + P) % P] + f[i - 1]) % mod;
}
}
x = 0;
for (int i = mid + 1; i <= r; ++i) {
x = (x + pw[a[i]]) % P;
f[i] = (f[i] + mp[x]) % mod;
}
cdq(mid + 1, r);
}
void solve() {
scanf("%lld", &n);
pw[0] = 1;
for (int i = 1; i < maxn; ++i) {
pw[i] = pw[i - 1] * 2 % P;
}
for (int i = 1; i <= n; ++i) {
scanf("%lld", &a[i]);
}
f[0] = 1;
cdq(1, n);
printf("%lld\n", f[n]);
}
int main() {
int T = 1;
// scanf("%d", &T);
while (T--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 5ms
memory: 14948kb
input:
5 2 0 0 1 1
output:
6
result:
ok 1 number(s): "6"
Test #2:
score: 0
Accepted
time: 5ms
memory: 15572kb
input:
1 0
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 5ms
memory: 14304kb
input:
2 1 1
output:
2
result:
ok 1 number(s): "2"
Test #4:
score: 0
Accepted
time: 5ms
memory: 14220kb
input:
3 2 1 1
output:
3
result:
ok 1 number(s): "3"
Test #5:
score: 0
Accepted
time: 0ms
memory: 15460kb
input:
4 3 2 2 3
output:
4
result:
ok 1 number(s): "4"
Test #6:
score: 0
Accepted
time: 5ms
memory: 14864kb
input:
5 3 4 4 2 4
output:
2
result:
ok 1 number(s): "2"
Test #7:
score: 0
Accepted
time: 0ms
memory: 15232kb
input:
7 3 4 3 5 6 3 4
output:
6
result:
ok 1 number(s): "6"
Test #8:
score: 0
Accepted
time: 0ms
memory: 14656kb
input:
10 8 6 5 6 7 8 6 8 9 9
output:
4
result:
ok 1 number(s): "4"
Test #9:
score: -100
Wrong Answer
time: 0ms
memory: 14664kb
input:
96 5 1 0 2 5 5 2 4 2 4 4 2 3 4 0 2 1 4 3 1 2 0 2 2 3 2 4 5 3 5 2 0 2 2 5 3 0 4 5 3 5 4 4 3 1 2 0 5 4 5 0 2 3 2 4 0 0 4 2 0 2 5 3 3 1 5 5 1 1 1 0 5 0 3 0 2 1 1 0 5 0 3 3 4 4 5 3 0 2 2 0 5 4 5 0 5
output:
1741824
result:
wrong answer 1st numbers differ - expected: '11332014', found: '1741824'