QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#559032 | #9221. Missing Boundaries | ucup-team2526 | WA | 65ms | 15612kb | C++20 | 2.0kb | 2024-09-11 19:47:34 | 2024-09-11 19:47:35 |
Judging History
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...);
}
void GENSHEN_START() {
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;
num.push_back(r);
if (vis[r]) ok = 1;
vis[l] = r;
vis[r] = 4e9;
}
}
//dbg(ok);
if (ok) {
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 (i == len - 1) {
if (num[i] != L && vis[num[i]] != 3e9) least++;
break;
}
if (num[i] != 1 && i == 0 && vis[num[i]] != 2e9) least++;
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 (nxt != num[i] + 1) least += 1;
}
}
else if (vis[num[i]] == 3e9) {
suit += nxt - num[i] - 1;
}
else {
if (nxt != vis[num[i]]) {
cout << "NIE" << '\n';
return ;
}
}
//dbg(i,num[i]);
}
//dbg(cnt,least,suit);
if (cnt < least) {
cout << "NIE" << '\n';
return ;
}
if (cnt > suit) {
cout << "NIE" << '\n';
return ;
}
cout << "TAK" << '\n';
return ;
}
signed main()
{
ios::sync_with_stdio(false);cin.tie(nullptr);
int T = 1;
cin >> T;
while (T--) GENSHEN_START();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3624kb
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 NIE NIE
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 65ms
memory: 15612kb
input:
1 200000 1000000000 490669427 -1 224278942 224287156 821104480 -1 861696576 861702036 807438935 807440055 574078002 574083717 465630141 -1 195378188 -1 -1 13500961 -1 977536179 92893115 -1 -1 661145418 -1 215804863 -1 685338515 544348999 -1 465532902 -1 130346949 -1 -1 526666304 635604584 635605404 ...
output:
NIE
result:
wrong answer 1st lines differ - expected: 'TAK', found: 'NIE'