QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#596691#9223. Data Determinationucup-team1074WA 303ms33768kbC++232.3kb2024-09-28 16:17:212024-09-28 16:17:24

Judging History

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

  • [2024-09-28 16:17:24]
  • 评测
  • 测评结果:WA
  • 用时:303ms
  • 内存:33768kb
  • [2024-09-28 16:17:21]
  • 提交

answer

// Problem: G - Data Determination
// Contest: Virtual Judge - The 3rd Universal Cup. Stage 8: Cangqian + The 3rd Universal Cup. Stage 7: Warsaw
// URL: https://vjudge.net/contest/658753#problem/G
// Memory Limit: 1014 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define x first
#define y second 
#define endl '\n'
const LL maxn = 4e05+7;
const LL N = 5e05+10;
const LL mod = 1e09+7;
const int inf = 0x3f3f3f3f;
const LL llinf = 5e18;
typedef pair<int,int>pl;
priority_queue<LL , vector<LL>, greater<LL> >mi;//小根堆
priority_queue<LL> ma;//大根堆
void solve() 
{
	int n , k , m;
	cin >> n >> k >> m;
	int ok = 0;
	set<int>st;
	int a[n];
	for(int i = 0 ; i < n ; i ++){
		cin >> a[i];	
		st.insert(a[i]);
	}
	map<int,int>mp;
	map<int,int>pm;
	int id = 0;
	for(auto it : st){
		mp[it] = ++id;
		pm[id] = it;
	}
	vector<int>cnt(id + 5 , 0);
	vector<int>pre(id + 5 , 0);
	for(int i = 0 ; i < n ; i++){
		pre[mp[a[i]]]++;
		cnt[mp[a[i]]]++;
	}
	for(int i = 1 ; i <= id ; i ++){
		pre[i] += pre[i - 1];
	}
	if(k & 1){
		int le = k / 2;
		int ri = k / 2;
		if(!mp.count(m)){
			cout << "NIE\n";
		}
		else{
			if(pre[mp[m] - 1] < le){
				cnt[mp[m]] -= le - pre[mp[m] - 1];
			}
			if(pre[id] - pre[mp[m]] < ri){
				cnt[mp[m]] -= ri - pre[id] + pre[mp[m]];
			}
			if(cnt[mp[m]] > 0){
				cout <<"TAK\n";
			}
			else{
				cout <<"NIE\n";
			}
		}
	}
	else{
		int l = 1 , r = id;
		while(l < r){
			while(pm[l] + pm[r] < m * 2){
				l++;
			}
			if(pm[l] + pm[r] > m * 2){
				r--;
				continue;
			}
			else{
				int le = k / 2 - 1;
				int ri = k / 2 - 1;
				int ok = 1;
				if(pre[l - 1] < le){
					if(cnt[l] <= le - pre[l - 1]){
						ok = 0;
					}
				}
				if(pre[id] - pre[r] < ri){
					if(cnt[r] <= ri - pre[id] + pre[r]){
						ok = 0;
					}
				}
				if(ok){
					cout << "TAK\n";
					return;
				}
				else{
					r--;
				}
			}
		}
		cout <<"NIE\n";
	}
}            
int main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(10);
    int t=1;
	cin>>t;
    while(t--)
    {
    	solve();
    }
    return 0;
}

詳細信息

Test #1:

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

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: 303ms
memory: 33768kb

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: 107ms
memory: 6528kb

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'