QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#724900#9223. Data DeterminationOkuchiri#WA 0ms3672kbC++202.6kb2024-11-08 15:29:192024-11-08 15:29:21

Judging History

你现在查看的是最新测评结果

  • [2024-11-08 15:29:21]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3672kb
  • [2024-11-08 15:29:19]
  • 提交

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;
        }
    }
    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: 0
Wrong Answer
time: 0ms
memory: 3672kb

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

result:

wrong answer 3rd lines differ - expected: 'NIE', found: ''