QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#530194 | #9221. Missing Boundaries | ucup-team4702# | WA | 62ms | 20508kb | C++17 | 2.0kb | 2024-08-24 15:20:26 | 2024-08-24 15:20:26 |
Judging History
answer
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <array>
#include <set>
using namespace std;
#ifdef ONLINE_JUDGE
#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
char buf[1 << 23], *p1 = buf, *p2 = buf, ubuf[1 << 23], *u = ubuf;
#endif
int read() {
int p = 0, flg = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-') flg = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
p = p * 10 + c - '0';
c = getchar();
}
return p * flg;
}
void write(int x) {
if (x < 0) {
x = -x;
putchar('-');
}
if (x > 9) {
write(x / 10);
}
putchar(x % 10 + '0');
}
bool _stmer;
class Node {
public:
bool flg1, flg2;
int l, r;
Node (bool _flg1, bool _flg2, int _l, int _r) : flg1(_flg1), flg2(_flg2), l(_l), r(_r) {}
bool operator <(const Node &t) const { return l < t.l; }
};
set <Node> isl;
void solve() {
isl.clear();
int n = read(), m = read();
int res = 0;
for (int i = 1; i <= n; i++) {
int x = read(), y = read();
if (x == -1 && y == -1) { res++; continue; };
Node now(0, 0, 0, 0);
if (x == -1) now.flg1 = 1, x = y;
if (y == -1) now.flg2 = 1, y = x;
now.l = x, now.r = y;
isl.insert(now);
}
isl.insert(Node(0, 0, 0, 0));
isl.insert(Node(0, 0, m + 1, m + 1));
int tp0 = 0, tp1 = 0;
for (auto it = isl.begin(); next(it, 1) != isl.end(); it++) {
auto et = next(it, 1);
if (it -> r + 1 == et -> l) continue;
if (et -> l <= it -> r) { return (void)puts("NIE"); }
tp0 += (!it -> flg2) && (!et -> flg1);
tp1 += et -> l - it -> r - 1;
}
if (tp0 <= res && res <= tp1)
puts("TAK");
else
puts("NIE");
}
bool _edmer;
int main() {
cerr << (&_stmer - &_edmer) / 1024.0 / 1024.0 << "MB\n";
int T = read();
while (T--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 6008kb
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: 0
Accepted
time: 62ms
memory: 20508kb
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:
TAK
result:
ok single line: 'TAK'
Test #3:
score: 0
Accepted
time: 1ms
memory: 5960kb
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 #4:
score: 0
Accepted
time: 47ms
memory: 18264kb
input:
1 197838 400000 34167 34169 352180 -1 235963 -1 -1 -1 160401 160405 347288 -1 270353 270354 214502 214504 183243 183245 -1 -1 -1 36193 -1 -1 -1 17557 273498 273500 269137 -1 395099 395100 285515 285518 -1 -1 71041 71042 324060 -1 -1 385151 -1 379645 -1 -1 -1 185142 -1 191584 89259 89261 328347 32834...
output:
TAK
result:
ok single line: 'TAK'
Test #5:
score: -100
Wrong Answer
time: 33ms
memory: 12420kb
input:
2 97340 150000 -1 101927 105937 -1 -1 107253 -1 47307 110550 -1 84061 84062 125176 125177 -1 15915 29617 -1 -1 -1 -1 43147 115958 -1 101807 101808 24866 -1 66826 66828 -1 31640 -1 5610 1281 1284 -1 -1 -1 -1 -1 73973 -1 2945 29064 -1 30653 -1 -1 63714 -1 -1 141389 141390 -1 27465 57358 -1 47388 47389...
output:
TAK TAK
result:
wrong answer 1st lines differ - expected: 'NIE', found: 'TAK'