QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#844926 | #9971. 新本格魔法少女りすか | ZnPdCo | 0 | 216ms | 49780kb | C++14 | 1.8kb | 2025-01-06 12:28:41 | 2025-01-06 12:28:41 |
Judging History
answer
#include <bits/stdc++.h>
#define N 500010
using namespace std;
int n, m, cnt, B;
int a[N];
struct seq {
int l, r, flag;
} b[N];
vector<int> c[N];
int ans[N];
int t[N], s[N];
void upd(int x, int v) {
x = n - x + 1;
while(x <= n) {
t[x] += v;
x += x & -x;
}
}
int qry(int x) {
x = n - x + 1;
int res = 0;
while(x) {
res += t[x];
x -= x & -x;
}
return res;
}
signed main() {
scanf("%d%d", &n, &m);
B = sqrt(n / log2(n));
n = (n + B - 1) / B * B;
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
}
for (int i = 1; i <= m; i++) {
int k;
scanf("%d", &k);
for (int j = 1; j <= k; j++) {
cnt++;
scanf("%d%d", &b[cnt].l, &b[cnt].r);
c[i].push_back(cnt);
}
}
// for (int l = 1, r = B; r <= n; l += B, r += B) {
// for (int i = 1; i <= n; i++) t[i] = 0, s[i] = 0;
// for (int i = l; i <= r; i++) t[a[i]]++;
// for (int i = n - 1; i >= 1; i--) t[i] += t[i + 1];
// for (int i = 1; i < l; i++) s[i] = t[a[i]];
// for (int i = 1; i <= m; i++) {
// bool flag = 0;
// for (int j : c[i]) if(b[j].l <= l && b[j].r >= r) flag = 1, b[j].flag = 1;
// if (!flag) continue;
// for (int j : c[i]) if (b[j].r < l) ans[i] += s[b[j].r] - s[b[j].l - 1]; else break;
// }
// }
// for (int i = 1; i <= m; i++) {
// memset(t, 0, sizeof t);
// for (int j : c[i]) {
// if (!b[j].flag) for (int k = b[j].l; k <= b[j].r; k++) ans[i] += qry(a[k]);
// for (int k = b[j].l; k <= b[j].r; k++) upd(a[k], 1);
// }
// }
// for (int i = 1; i <= m; i++) cout << ans[i] << endl;
}
详细
Subtask #1:
score: 0
Time Limit Exceeded
Test #1:
score: 0
Time Limit Exceeded
input:
500000 50174 453952 363686 491616 32825 57465 422945 471561 73291 421205 416554 23295 133266 242225 330448 25039 340064 28713 465664 162059 323880 28978 273728 101338 161413 294941 214275 63951 267981 294251 202822 253124 272510 3268 37918 139343 385983 111577 311901 487665 482827 347449 416029 3065...
output:
result:
Subtask #2:
score: 0
Wrong Answer
Test #6:
score: 0
Wrong Answer
time: 216ms
memory: 49780kb
input:
500000 5 157360 289139 98034 293691 150262 268366 36782 147093 365410 444658 343224 375392 278298 357620 389673 167019 7747 119244 102126 83512 3649 459230 197365 245259 38071 249539 34617 213697 292553 389625 395778 280152 280038 239519 301475 232272 145919 370004 422791 271143 488283 185166 351026...
output:
result:
wrong answer Answer contains longer sequence [length = 5], but output contains 0 elements
Subtask #3:
score: 0
Skipped
Dependency #1:
0%