QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#596809#9223. Data Determinationucup-team1074Compile Error//C++232.5kb2024-09-28 16:29:262024-09-28 16:29:26

Judging History

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

  • [2024-09-28 16:29:26]
  • 评测
  • [2024-09-28 16:29:26]
  • 提交

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;
#define int long long
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);
	int b[n];
	for(int i = 0 ; i < n ; i ++){
		b[i] = mp[a[i]];
	}
	int t = mp[m];
	for(int i = 0 ; i < n ; i++){
		pre[b[i]]++;
		cnt[b[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[t] -= le - pre[t - 1];
			}
			if(pre[id] - pre[mp[m]] < ri){
				cnt[t] -= ri - pre[id] + pre[t];
			}
			if(cnt[t] > 0){
				cout <<"TAK\n";
			}
			else{
				cout <<"NIE\n";
			}
		}
	}
	else{
		int l = 1 , r = id;
		while(l <= r){
			while(l < r && pm[l] + pm[r] < m * 2){
				l++;
			}
			if(pm[l] + pm[r] > m * 2){
				r--;
				continue;
			}
			else if(pm[l] + pm[r] == m * 2){
				int le = k / 2 - 1;
				int ri = k / 2 - 1;
				int ok = 1;
				if(l == r){
					if(	cnt[l] < 2 + max(0LL , le - pre[l - 1]) + max(0LL , ri - pre[id] + pre[r])){
						ok = 0;
					}
				}
				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--;
				}
			}
		}
		else{
			r--;
		}
		cout <<"NIE\n";
	}
}            
signed 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;
}

Details

answer.code: In function ‘void solve()’:
answer.code:116:17: error: ‘else’ without a previous ‘if’
  116 |                 else{
      |                 ^~~~