QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#721777#9223. Data DeterminationciuimWA 113ms30488kbC++142.6kb2024-11-07 16:48:352024-11-07 16:48:36

Judging History

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

  • [2024-11-07 16:48:36]
  • 评测
  • 测评结果:WA
  • 用时:113ms
  • 内存:30488kb
  • [2024-11-07 16:48:35]
  • 提交

answer

bool M1;
#define look_memory cerr<<abs(&M2-&M1)/1024.0/1024<<" MB\n"
#define look_time cerr<<(clock()-Time)*1.0/CLOCKS_PER_SEC<<'\n'
#include <cstdio>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <cstring>
#include <array>
#include <algorithm>
#include <queue>
#include <vector>
#include <bitset>
#include <ctime>
#include <cstdlib>
#include <random>
#include <set>
#include <ctime>
#include <map>
#include <stack>
#include <unordered_map>
#include <assert.h>
#define i128 __int128
#define ll long long
#define uint unsigned
#define ull unsigned long long
#define ld long double
#define fo(a,b,c) for(ll a=b;a<=c;++a)
#define re(a,b,c) for(ll a=b;a>=c;--a)
#define pii pair<ll,ll>
#define pdd pair<db,db>
#define fi first
#define pb push_back
#define se second
#define ite set<ll> ::iterator
#define vite vector<ll> ::iterator
using namespace std;
const ll mod=998244353;
inline ll gi()
{
	ll x = 0, f = 1;
	char ch = getchar();
	while(ch < '0' || ch > '9')
	{
		if (ch == '-')
			f = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9')
	{
		x = (x<<1) + (x<<3) + (ch^48);
		ch = getchar();
	}
	return x * f;
}
ll _=1;
const ll inf=2e17+5,iinf=1e9;
const ll N=200005;
ll a[N];
map<ll,ll> mp;
void sol()
{
	ll n=gi(),k=gi(),m=gi();
	fo(i,1,n) a[i]=gi();
	sort(a+1,a+1+n);
	mp.clear();
	fo(i,1,n) mp[a[i]]++;
	if(k%2)
	{
		if(mp[m]==0)
		{
			cout<<"NIE";
			return;
		}
		ll ok=0;
		if(mp[m]!=0) ok=1,mp[m]--;
		ll rs=k/2;
		fo(i,1,n)
		{
			if(a[i]<=m)
			{
				if(mp[a[i]]!=0)
				{
					mp[a[i]]--;
					rs--;
				}
			}
			if(rs==0) break;
		}
		if(rs) ok=0;
		rs=k/2;
		fo(i,1,n)
		{
			if(a[i]>=m)
			{
				if(mp[a[i]]!=0)
				{
					mp[a[i]]--;
					rs--;
				}
			}
			if(rs==0) break;
		}
		if(rs) ok=0;
		if(ok) cout<<"TAK";
		else cout<<"NIE";
		return;
	}
	ll mn=inf;
	fo(i,1,n)
	{
		if(mp[a[i]]!=0&&mp[m*2-a[i]]!=0&&a[i]!=m)
		{
			mn=min(mn,abs(m-a[i]));
		}
	}
	if(mp[m]>=2) mn=0;
	if(mn==inf)
	{
		cout<<"NIE";
		return;
	}
	ll l=m-mn,r=m+mn;
	mp[l]--;
	mp[r]--;
	ll ok=1;
	ll rs=k/2-1;
	fo(i,1,n)
	{
		if(a[i]<=l)
		{
			if(mp[a[i]]!=0)
			{
				mp[a[i]]--;
				rs--;
			}
		}
		if(rs==0) break;
	}
	if(rs) ok=0;
	rs=k/2-1;
	fo(i,1,n)
	{
		if(a[i]>=r)
		{
			if(mp[a[i]]!=0)
			{
				mp[a[i]]--;
				rs--;
			}
		}
		if(rs==0) break;
	}
	if(rs) ok=0;
	if(ok)
	{
		cout<<"TAK";
	}
	else cout<<"NIE";
}
bool M2;
int main()
{
	int Time=clock();
	look_memory;
	_=gi();
	while(_--)
	{
		sol();
		printf("\n");
	}
	look_time;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 4020kb

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: 113ms
memory: 30488kb

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: 52ms
memory: 6644kb

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: -100
Wrong Answer
time: 41ms
memory: 6648kb

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
NIE
NIE
TAK

result:

wrong answer 8th lines differ - expected: 'TAK', found: 'NIE'