QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#559150#9221. Missing Boundariesucup-team2526WA 0ms3540kbC++202.8kb2024-09-11 20:31:162024-09-11 20:31:16

Judging History

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

  • [2024-09-11 20:31:16]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3540kb
  • [2024-09-11 20:31:16]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long

#define dbg(x...) \
do { \
std::cout << #x << " -> "; \
err(x); \
} while (0)

void err() {
	std::cout << std::endl;
}

template<class T, class... Ts>
void err(T arg, Ts &... args) {
	std::cout << fixed << setprecision(10) << arg << ' ';
	err(args...);
}

int ti;
int ttt;

void GENSHEN_START() {
	ttt++;
	int n,L;cin >> n >> L;
	unordered_map<int,int>vis;
	vector<int>num;
	int cnt = 0;
	int ok = 0;
	for (int i = 1;i <= n;i++) {
		int l,r;cin >> l >> r;
		if (l == -1 && r == -1) {
			cnt++;
		}
		else if (r == -1) {
			num.push_back(l);
			if (vis[l]) ok = 1;
			vis[l] = 3e9;
		}
		else if (l == -1) {
			num.push_back(r);
			if (vis[r]) ok = 1; 
			vis[r] = 2e9;	
		}
		else {
			num.push_back(l);
			if (vis[l]) ok = 1;
			if (vis[r]) ok = 1;
			if (l == r) {
				vis[l] = 5e9;	
			}
			else {
				num.push_back(r);
				vis[l] = r;
				vis[r] = 4e9;	
			}
		}
	}
	//dbg(ok);
	if (ok) {
		//if (ti == 1) cout << "no";
		cout << "NIE" << '\n';
		return ;
	}
	sort(num.begin(),num.end());
	int len = num.size();
	int suit = 0,least = 0;
	for (int i = 0;i < len;i++) {
		if (num[i] != 1 && i == 0 && vis[num[i]] != 2e9) least++;
		if (num[i] != 1 && i == 0 && vis[num[i]] == 2e9) suit += num[i] - 1;
		if (i == len - 1) {
			if (num[i] != L && vis[num[i]] != 3e9) least++;
			if (num[i] != L && vis[num[i]] == 3e9) suit += L - num[i];
			break;
		}
		int nxt = num[i + 1];
		if (vis[num[i]] == 2e9) {
			if (vis[nxt] == 2e9) {
				suit += nxt - num[i] - 1;
			}
			else if (vis[nxt] == 3e9) {
				if (nxt != num[i] + 1) least += 1;
			}
			else if (vis[nxt] == 5e9) {
				if (nxt != num[i] + 1) least += 1;
			}
			else {
				if (nxt != num[i] + 1) least += 1;
			}
		}
		else if (vis[num[i]] == 5e9) {
			if (vis[nxt] == 2e9) {
				suit += nxt - num[i] - 1;
			}
			else if (vis[nxt] == 3e9) {
				if (nxt != num[i] + 1) least += 1;
			}
			else {
				if (nxt != num[i] + 1) least += 1;
			}
		}
		else if (vis[num[i]] == 3e9) {
			suit += nxt - num[i] - 1;
		}
		else if (vis[num[i]] == 4e9) {
			if (vis[nxt] == 2e9) {
				suit += nxt - num[i] - 1;
			}
			else if (vis[nxt] == 3e9) {
				if (nxt != num[i] + 1) least += 1;
			}
			else {
				if (nxt != num[i] + 1) least += 1;
			}
		}
		else {
			if (nxt != vis[num[i]]) {
				cout << "NIE" << '\n';
				return ;
			}
		}
	}
	if (len == 0) {
		suit = n;
	}
	//if (ti == 30000 && ttt == 21) dbg(n,L,cnt,least,suit);
	if (cnt < least) {
		cout << "NIE" << '\n';
		return ;
	}
	if (cnt - least > suit) {
		cout << "NIE" << '\n';
		return ;
	}
	cout << "TAK" << '\n';
	return ;
}

signed main()
{
	ios::sync_with_stdio(false);cin.tie(nullptr);
	int T = 1;
	cin >> T;
	ti = T;
	while (T--) GENSHEN_START();
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3540kb

input:

3
4 51
1 -1
11 50
-1 -1
-1 10
3 2
-1 -1
-1 -1
-1 -1
2 3
1 2
2 3

output:

TAK
TAK
NIE

result:

wrong answer 2nd lines differ - expected: 'NIE', found: 'TAK'