QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#787862 | #9221. Missing Boundaries | ucup-team2179# | WA | 35ms | 16088kb | C++23 | 1.8kb | 2024-11-27 14:59:20 | 2024-11-27 14:59:20 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define db double
#define ll long long
#define pii pair<int, int>
using namespace std;
const int N = 4e5 + 999;
int n, L, m, ok[N], l[N], r[N];
pii p[N];
void solve() {
cin >> n >> L;
m = 0;
int s = 0;
bool flag = 1;
for (int i = 1; i <= n; i++){
cin >> l[i] >> r[i];
if(l[i] != -1 && r[i] != -1){
ok[i] = 3;
p[++m] = make_pair(l[i], i);
}
else if(l[i] != -1){
ok[i] = 1;
p[++m] = make_pair(l[i], i);
}
else if(r[i] != -1){
ok[i] = 2;
p[++m] = make_pair(r[i], i);
}
else
s++;
}
p[++m] = make_pair(0, m);
p[++m] = make_pair(L + 1, m);
ok[m] = ok[m - 1] = 3;
sort(p + 1, p + m + 1);
int nd = 0, s1 = 0;
for (int i = 2; i <= m; i++){
auto [x, id] = p[i];
auto [xx, lid] = p[i - 1];
//cout << id << ' ';
if(x <= xx){
flag = 0;
break;
}
if(ok[lid] == 1){
if(ok[id] == 2){
s1 += x - xx - 1;
}
else {
s1 += x - xx - 1;
}
}
else {
if(ok[id] == 2){
s1 += x - xx - 1;
}
else {
if(x - xx > 1)
nd++;
s1 += (x - xx - 1);
}
}
}
if(s < nd || s > s1)
flag = 0;
if(flag)
cout << "TAK\n";
else
cout << "NIE\n";
}
signed main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int t = 1;
cin >> t;
while (t--)
solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 9700kb
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: 35ms
memory: 16088kb
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'