QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#555218 | #9223. Data Determination | ucup-team2526 | WA | 117ms | 29892kb | C++20 | 2.3kb | 2024-09-09 20:46:37 | 2024-09-09 20:46:37 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define dbg(x...) \
do { \
std::cout << #x << " -> "; \
err(x); \
} while (0)
void err() {
std::cout << std::endl;
}
template<class T, class... Ts>
void err(T arg, Ts &... args) {
std::cout << fixed << setprecision(10) << arg << ' ';
err(args...);
}
void GENSHEN_START() {
int n,k,m;cin >> n >> k >> m;
vector<int>a(n + 5);
map<int,int>mp;
for (int i = 1; i <= n; ++i) {
cin >> a[i];
mp[a[i]]++;
}
sort(a.begin() + 1,a.begin() + 1 + n);
if (k % 2) {
if (!mp[m]) {
cout << "NIE" << '\n';
return ;
}
int cnt = 0,cnt0 = 0,cnt1 = 0;
for (int i = 1; i <= n; ++i) {
if (a[i] == m) cnt++;
else if (a[i] < m) cnt0++;
else cnt1++;
}
cnt--;
if (cnt0 < k / 2) {
if (cnt0 + cnt >= k / 2) cout << "TAK" << '\n';
else cout << "NIE" << '\n';
return ;
}
else if (cnt1 < k / 2) {
if (cnt1 + cnt >= k / 2) cout << "TAK" << '\n';
else cout << "NIE" << '\n';
return ;
}
else if (cnt0 < k / 2 && cnt1 < k / 2) {
if (cnt0 + cnt >= k / 2 && cnt1 + (cnt - k / 2 + cnt0) >= k / 2) cout << "TAK" << '\n';
else cout << "NIE" << '\n';
return ;
}
}
else {
for (int i = 1; i <= n; ++i) {
if (mp[m * 2 - a[i]]) {
int l = min(a[i],m * 2 - a[i]),r = max(a[i],m * 2 - a[i]);
//dbg(l,r);
int upr = upper_bound(a.begin() + 1,a.begin() + 1 + n,r) - a.begin();
upr = n - upr + 1;
int downl = lower_bound(a.begin() + 1,a.begin() + 1 + n,l) - a.begin() - 1;
//dbg(downl,upr);
if (l == r) {
int cnt = mp[l] - 2;
if (downl < k / 2 - 1) {
cnt -= k / 2 - 1 - downl;
}
if (upr < k / 2 - 1) {
cnt -= k / 2 - 1 - upr;
}
if (cnt >= 0) {
cout << "TAK" << '\n';
return ;
}
}
else {
int cntl = mp[l] - 1,cntr = mp[r] - 1;
if (downl < k / 2 - 1) {
cntl -= k / 2 - 1 - downl;
}
if (upr < k / 2 - 1) {
cntr -= k / 2 - 1 - upr;
}
if (cntl >= 0 && cntr >= 0) {
cout << "TAK" << '\n';
return ;
}
}
}
}
cout << "NIE" << '\n';
}
}
signed main() {
ios::sync_with_stdio(false);cin.tie(nullptr);
int T = 1;
cin >> T;
while (T--) GENSHEN_START();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3784kb
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: 117ms
memory: 29892kb
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: 0
Accepted
time: 62ms
memory: 5768kb
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 NIE NIE NIE NIE NIE
result:
ok 10 lines
Test #4:
score: 0
Accepted
time: 54ms
memory: 6004kb
input:
10 20000 6 569116309 533654855 569116308 512534907 569116310 500238175 562175605 569116308 569116310 489499020 543748669 569116309 526641247 511510060 504576222 569116309 569116310 569116308 569116310 569116309 569116308 569116309 569116310 569116308 569116310 569116309 569116308 465300463 569116308...
output:
TAK TAK NIE NIE NIE NIE NIE TAK NIE TAK
result:
ok 10 lines
Test #5:
score: -100
Wrong Answer
time: 49ms
memory: 11092kb
input:
1 200000 99999 519401084 60561374 111262859 724696443 994449169 60561374 44352999 44352999 994449169 333890219 44352999 326562388 994449169 60561374 994449169 111262859 614556033 60561374 994449169 60561374 994449169 44352999 994449169 60561374 335786619 994449169 994449169 629087444 44352999 464308...
output:
result:
wrong answer 1st lines differ - expected: 'TAK', found: ''