QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#434796 | #8781. Element-Wise Comparison | ucup-team055# | WA | 92ms | 3720kb | C++23 | 2.2kb | 2024-06-08 17:25:28 | 2024-06-08 17:25:29 |
Judging History
answer
#pragma GCC target("avx512f,avx512dq,avx512vl,prefer-vector-width=512")
#pragma GCC optimize("Ofast,unroll-loops")
//#include <immintrin.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); i++)
mt19937 rnd;
using u16 = uint16_t;
using u32 = uint32_t;
u16 N, M;
u16 P[1 << 16];
constexpr int W = 32;
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> N >> M;
rep(i, 0, N) cin >> P[i];
// N = 50000;
// M = 3;
// rep(i, 0, N) P[i] = i + 1;
// shuffle(P, P + N, rnd);
u16 Ms[W] = {};
rep(i, 0, W) Ms[i] = M;
u32 ans = 0;
int ii = 1;
for(; ii + W < N - M; ii += W) {
// 幅 ii から幅 ii + 31 まで
u16 cnt[W] = {};
u16 add[W] = {};
int i = ii;
for(; i + W <= N; i++) {
u16 L[W], R[W];
rep(j, 0, W) L[j] = P[i - ii];
rep(j, 0, W) R[j] = P[ii + j];
rep(j, 0, W) {
// 幅 ii + j
if(L[j] < R[j]) {
cnt[j]++;
} else {
cnt[j] = 0;
}
}
rep(j, 0, W) if(cnt[j] >= Ms[j]) {
add[j]++;
}
}
for(; i < N; i++) {
u16 L[W], R[W];
rep(j, 0, W) L[j] = P[i - ii];
rep(j, 0, W) {
if(ii + j >= N) break;
R[j] = P[ii + j];
}
rep(j, 0, W) {
if(ii + j >= N) break;
// 幅 ii + j
if(L[j] < R[j]) {
cnt[j]++;
if(cnt[j] >= Ms[j]) {
add[j]++;
}
} else {
cnt[j] = 0;
}
}
}
for(auto x : add) ans += x;
}
for(; ii <= N - M; ii++) {
// 幅 ii
u16 cnt = 0;
rep(j, ii, N) {
if(P[j - ii] < P[j]) {
cnt++;
} else {
cnt = 0;
}
if(cnt >= M) ans++;
}
}
cout << ans << endl;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3720kb
input:
5 3 5 2 1 3 4
output:
0
result:
ok answer is '0'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
5 2 3 1 4 2 5
output:
2
result:
ok answer is '2'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3708kb
input:
4 2 1 2 3 4
output:
3
result:
ok answer is '3'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3660kb
input:
4 2 4 3 2 1
output:
0
result:
ok answer is '0'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
1 1 1
output:
0
result:
ok answer is '0'
Test #6:
score: -100
Wrong Answer
time: 92ms
memory: 3712kb
input:
50000 2 44045 29783 5389 7756 44022 45140 21967 5478 10868 49226 21775 31669 49836 13511 46116 14229 27206 31168 37389 3158 10658 41154 14635 18526 40540 6451 23197 46719 30593 13517 8604 46666 39189 43746 12778 3684 3194 36979 43020 14652 19549 31178 17144 27177 44336 2849 40220 11751 41993 32209 4...
output:
417919883
result:
wrong answer expected '310780127', found '417919883'