QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#724902 | #9223. Data Determination | Okuchiri# | WA | 225ms | 30292kb | C++20 | 2.7kb | 2024-11-08 15:30:03 | 2024-11-08 15:30:04 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,k,x;
map<ll,ll>b;
ll a[200010];
map<ll,ll>q;
void solve()
{
cin>>n>>k>>x;
b.clear();
q.clear();
for(int i=1;i<=n;i++)
{
cin>>a[i],b[a[i]]=b[a[i]]+1;
}
sort(a+1,a+n+1);
for(int i=1;i<=n;i++)
{
q[a[i]]=q[a[i-1]]+1;
}
if(k%2==1)
{
if(b[x]==0)
{
cout<<"NIE\n";
return;
}
ll cnt1=0,cnt2=0;
for(int i=1;i<=n;i++)
{
if(a[i]<x)cnt1++;
if(a[i]>x)cnt2++;
}
ll tar=k/2,t=b[x]-1;
if(cnt1>cnt2)swap(cnt1,cnt2);
if(cnt1<tar&&cnt2<tar)
{
if(t+cnt1+cnt2>=2*tar)
{
cout<<"TAK\n";
return;
}
}
else if(cnt1<tar)
{
if(t+cnt1>=tar)
{
cout<<"TAK\n";
return;
}
}
else
{
cout<<"TAK\n";
return;
}
cout<<"NIE\n";
}
else
{
for(int i=1;i<=n;i++)
{
if(b[2*x-a[i]]==0)
{
b.erase(2*x-a[i]);
continue;
}
ll x1=a[i],y1=2*x-a[i];
if(x1!=y1)
{
ll cnt1=q[a[i]]-1;
ll cnt2=n-(q[y1]-b[y1])-1;
if(cnt1>=k/2-1&&cnt2>=k/2-1)
{
cout<<"TAK\n";
return;
}
}
else
{
ll cnt1=q[x]-b[x];
ll cnt2=n-q[x];
ll tar=k/2-1,t=b[x]-2;
if(b[x]<2)continue;
if(cnt1>cnt2)swap(cnt1,cnt2);
if(cnt1<tar&&cnt2<tar)
{
if(t+cnt1+cnt2>=2*tar)
{
cout<<"TAK\n";
return;
}
}
else if(cnt1<tar)
{
if(t+cnt1>=tar)
{
cout<<"TAK\n";
return;
}
}
else
{
cout<<"TAK\n";
return;
}
}
}
cout<<"NIE\n";
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll T = 1;
cin >> T;
while(T--)
{
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3588kb
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: 225ms
memory: 30292kb
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: 89ms
memory: 6320kb
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:
TAK TAK TAK NIE TAK TAK NIE NIE TAK TAK
result:
wrong answer 1st lines differ - expected: 'NIE', found: 'TAK'