QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#579441 | #9223. Data Determination | BerryPie# | WA | 202ms | 15508kb | C++20 | 1.9kb | 2024-09-21 13:46:22 | 2024-09-21 13:46:23 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200000+5;
int n, k, m, N;
int a[MAXN], b[MAXN], bit[MAXN];
vector<int> vec;
map<int, int> mp;
void add(int x, int v){
for(int i = x; i <= N; i += i&-i){
bit[i] += v;
}
}
int query(int x){
int res = 0;
for(int i = x; i; i -= i&-i){
res += bit[i];
}
return res;
}
int qsum(int l, int r){
return query(r) - query(l-1);
}
int solve(){
for(int i = 1; i <= N; i++){
bit[i] = 0;
}
for(int i = 1; i <= n; i++){
add(b[i], 1);
}
for(int i = 1; i <= n; i++){
int x = a[i];
if(k&1){
if(x != m) continue;
x = mp[x];
add(x, -1);
if(qsum(1, x) >= (k-1)/2 && qsum(x, N) >= (k-1)/2){
return 1;
}
add(x, 1);
}
else{
int y = 2*m-x;
if(!mp.count(y)) continue;
if(x > y) swap(x, y);
x = mp[x];
y = mp[y];
add(x, -1);
add(y, -1);
if(qsum(1, x) >= (k-2)/2 && qsum(y, N) >= (k-2)/2){
return 1;
}
add(x, 1);
add(y, 1);
}
}
return 0;
}
int main(){
int kase;
cin >> kase;
while(kase--){
cin >> n >> k >> m;
vec.clear();
for(int i = 1; i <= n; i++){
cin >> a[i];
vec.push_back(a[i]);
}
sort(vec.begin(), vec.end());
vec.erase(unique(vec.begin(), vec.end()), vec.end());
N = vec.size();
mp.clear();
for(int i = 1; i <= n; i++){
b[i] = lower_bound(vec.begin(), vec.end(), a[i]) - vec.begin() + 1;
mp[a[i]] = b[i];
}
cout << (solve() ? "TAK" : "NIE") << "\n";
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3612kb
input:
3 6 4 42 41 43 41 57 41 42 4 2 4 1 2 5 8 7 5 57 101 2 42 5 57 7 13
output:
TAK NIE NIE
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 202ms
memory: 15508kb
input:
1 200000 2 482043846 410684388 380438852 309193412 468460689 586281084 680820569 266819813 639025900 488292166 503516930 532292185 618277661 728546481 628339224 673945619 471325257 372807753 325778059 372151033 548358519 276494019 336701079 320784795 377493322 385262271 621712987 349634764 668994576...
output:
NIE
result:
ok single line: 'NIE'
Test #3:
score: -100
Wrong Answer
time: 113ms
memory: 4804kb
input:
10 20000 3530 502140211 367996343 553577602 581694419 435810361 532394401 431613294 485360190 608191058 506969937 531905607 429252296 360241499 519031654 250454430 478548102 753825992 450326073 603766643 566036856 511634983 416622101 753825992 753825992 380511285 390746506 436237616 342529443 878920...
output:
NIE TAK TAK NIE TAK TAK NIE NIE NIE NIE
result:
wrong answer 6th lines differ - expected: 'NIE', found: 'TAK'