QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#440753 | #8781. Element-Wise Comparison | ucup-team3695 | RE | 0ms | 3812kb | C++20 | 1.1kb | 2024-06-14 00:50:29 | 2024-06-14 00:50:29 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define F first
#define S second
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int a[10];
int r[10];
bitset<10> g[10];
bitset<10> ands[10];
int main() {
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
int n,k;cin>>n>>k;
rep(i,0,n)cin>>a[i];
rep(i,0,n)--a[i];
rep(i,0,n)r[a[i]]=i;
for(int i = n-2; i >= 0; i--){
g[r[i]]=g[r[i+1]];
g[r[i]][r[i+1]]=1;
}
rep(i,1,n)g[i]>>=i;
ll ans = 0;
bitset<10> window;
for (int thresh = k-1; thresh < n; thresh += k) {
ands[thresh] = g[thresh];
for (int i = thresh-1; i > thresh-k; i--) {
ands[i] = ands[i+1] & g[i];
}
window = g[thresh];
for (int j = thresh-k+1; j <= min(thresh, n-k); j++) {
window = window & g[j+k-1];
ans += (window & ands[j]).count();
}
}
cout<<ans<<'\n';
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3528kb
input:
5 3 5 2 1 3 4
output:
0
result:
ok answer is '0'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3528kb
input:
5 2 3 1 4 2 5
output:
2
result:
ok answer is '2'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
4 2 1 2 3 4
output:
3
result:
ok answer is '3'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
4 2 4 3 2 1
output:
0
result:
ok answer is '0'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
1 1 1
output:
0
result:
ok answer is '0'
Test #6:
score: -100
Runtime Error
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...