QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#34110 | #1964. Stock Price Prediction | water233# | Compile Error | / | / | C++ | 3.0kb | 2022-06-05 16:46:25 | 2022-06-05 16:46:27 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2022-06-05 16:46:27]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2022-06-05 16:46:25]
- 提交
answer
#include <bits/stdc++.h>
using namespace std;
constexpr int maxn = 2e4 + 5, mod = 998244353, B = 1307;
mt19937 hua(512);
inline int add(int a, int b) {return (a += b) >= mod ? a - mod : a;}
inline int mul(int a, int b) {return 1ll * a * b % mod;}
inline int fpw(int a, int b) {
int ans = 1;
for(; b; b >>= 1, a = mul(a, a)) if(b & 1) ans = mul(ans, a);
return ans;a
}
int pwr[maxn], prepwr[maxn];
struct Fhq {
int rnd[maxn], ls[maxn], rs[maxn], sz[maxn], tag[maxn];
int val[maxn], pos[maxn], sum[maxn], rt;
vector<int> rollback;
int cnt;
Fhq() { cnt = rt = 0;}
int newnode(int x, int k) {
int u;
if(rollback.size()) u = rollback.back(), rollback.pop_back();
else u = ++ cnt;
val[u] = x, pos[u] = k, rnd[u] = hua() % mod, ls[u] = rs[u] = 0;
sum[u] = k, tag[u] = 0, sz[u] = 1;
return u;
}
void up(int u) {
sz[u] = sz[ls[u]] + sz[rs[u]] + 1;
sum[u] = add(sum[ls[u]], add(mul(pwr[sz[ls[u]]], pos[u]), mul(pwr[sz[ls[u]] + 1], sum[rs[u]])));
}
void seta(int u, int k) {
pos[u] -= k, tag[u] += k, sum[u] = add(sum[u], mod - mul(k, prepwr[sz[u] - 1]));
}
void dw(int u) {
if(tag[u]) {
seta(ls[u], tag[u]);
seta(rs[u], tag[u]);
tag[u] = 0;
}
}
void split(int u, int &x, int &y, int k, int p) {
if(!u) return x = y = 0, void();
dw(u);
if(val[u] < k || val[u] == k && pos[u] <= p) x = u, split(rs[u], rs[x], y, k, p);
else y = u, split(ls[u], x, ls[y], k, p);
up(u);
}
int merge(int u, int v) {
if(!u || !v) return u + v;
dw(u), dw(v);
if(rnd[u] < rnd[v]) {
rs[u] = merge(rs[u], v), up(u);
return u;
}
else {
ls[v] = merge(u, ls[v]), up(v);
return v;
}
}
void ins(int x, int k) {
int A, B;
split(rt, A, B, x, k);
rt = merge(A, merge(newnode(x, k), B));
}
void del(int x, int k) {
int A, B, C;
split(rt, A, B, x - 1, k);
split(B, B, C, x, k);
rollback.emplace_back(B);
rt = merge(A, C);
}
int qry() {
return sum[rt];
}
void dfs(int u) {
if(!u) return;
dw(u);
dfs(ls[u]), cout << u << ' ' << val[u] << ' ' << pos[u] << ' ' << sz[u] << ' ' << sum[u] << '\n', dfs(rs[u]);
up(u);
}
};
void init() {
pwr[0] = prepwr[0] = 1;
for(int i = 1; i < maxn; i ++) pwr[i] = mul(pwr[i - 1], B), prepwr[i] = add(prepwr[i - 1], pwr[i]);
}
int main() {
// freopen("in.txt", "r", stdin);
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
init();
int n, m;
Fhq t1, t2;
cin >> m >> n;
vector<int> a(m), b(n);
for(int i = 0; i < m; i ++) cin >> a[i];
for(int i = 0; i < n; i ++) cin >> b[i];
for(int i = 0; i < m; i ++) {
// cout << a[i] << ' ' << i << '\n';
t1.ins(a[i], i + 1);
// cout << "------------\n";
// t1.dfs(t1.rt);
}
int ret = t1.qry();
for(int i = 0; i < m - 1; i ++) {
t2.ins(b[i], i + 1);
}
int flag = 0;
for(int i = m - 1; i < n; i ++) {
t2.ins(b[i], m);
// cout << t2.qry() << " ------------\n";
// t2.dfs(t2.rt);
if(t2.qry() == ret) cout << i - m + 2 << ' ', flag = 1;
t2.del(b[i - m + 1], 1);
t2.seta(t2.rt, 1);
}
if(!flag) cout << 0 << '\n';
return 0;
}
详细
answer.code: In function ‘int fpw(int, int)’: answer.code:10:21: error: expected ‘;’ before ‘}’ token 10 | return ans;a | ^ | ; 11 | } | ~