QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#56092 | #3007. Intersecting Rectangles | YaoBIG# | AC ✓ | 142ms | 15892kb | C++ | 1.8kb | 2022-10-16 22:09:17 | 2022-10-16 22:09:19 |
Judging History
answer
#include "bits/stdc++.h"
#define rep(i, a, n) for (auto i = a; i <= (n); ++i)
#define revrep(i, a, n) for (auto i = n; i >= (a); --i)
#define all(a) a.begin(), a.end()
#define sz(a) (int)(a).size()
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class A> string to_string(A v) {
bool first = 1;
string res = "{";
for (const auto &x: v) {
if (!first) res += ", ";
first = 0;
res += to_string(x);
}
res += "}";
return res;
}
void debug_out() { cerr << endl; }
template<class Head, class... Tail> void debug_out(Head H, Tail... T) {
cerr << " " << to_string(H);
debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
int main() {
ios::sync_with_stdio(0); cin.tie(0);
int n; cin >> n;
using node = tuple<int, int, int, int>;
vector<node> ops;
rep(i, 0, n - 1) {
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
ops.emplace_back(x1, y1, y2, 1);
ops.emplace_back(x2, y1, y2, -1);
}
sort(all(ops));
reverse(all(ops));
set<int> S;
int ok = 0;
while (sz(ops)) {
// debug(S);
int nowx = get<0>(ops.back());
vector<node> tmp;
while (sz(ops) && get<0>(ops.back()) == nowx) {
tmp.push_back(ops.back());
ops.pop_back();
}
sort(all(tmp), [](node a, node b) { return get<1>(a) < get<1>(b); });
int tot = sz(tmp);
rep(i, 0, tot - 2) {
if (get<2>(tmp[i]) >= get<1>(tmp[i + 1])) ok = 1;
}
for (auto [x, y1, y2, op]: tmp) {
auto it = S.upper_bound(y1);
if (it != S.end() && *it < y2) ok = 1;
}
for (auto [x, y1, y2, op]: tmp) if (op == 1) {
S.emplace(y1);
S.emplace(y2);
}
for (auto [x, y1, y2, op]: tmp) if (op == -1) {
S.erase(y1);
S.erase(y2);
}
}
printf("%d\n", ok);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 73ms
memory: 7520kb
input:
100000 -1000000 -1000000 -990000 -990000 -989500 -999999 -979500 -989999 -979000 -999998 -969000 -989998 -968500 -999997 -958500 -989997 -958000 -999996 -948000 -989996 -947500 -999995 -937500 -989995 -937000 -999994 -927000 -989994 -926500 -999993 -916500 -989993 -916000 -999992 -906000 -989992 -90...
output:
0
result:
ok answer is 0
Test #2:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
1 -1000000000 -1000000000 1000000000 1000000000
output:
0
result:
ok answer is 0
Test #3:
score: 0
Accepted
time: 2ms
memory: 3768kb
input:
13 7516209 7550707 89875156 98173013 47476247 5897894 76370217 37077815 8554547 13903693 70271199 58517091 59377179 10691227 85248839 74526588 25381296 75287750 63190532 94490939 1744167 1968914 33149094 90583877 3729241 63828859 70195565 67888762 23931088 47849774 35764715 67174851 82068785 3054639...
output:
1
result:
ok answer is 1
Test #4:
score: 0
Accepted
time: 47ms
memory: 7464kb
input:
100000 -10000000 -10000000 -9999802 -9999804 -9999800 -9999800 -9999602 -9999604 -9999600 -9999600 -9999402 -9999404 -9999400 -9999400 -9999202 -9999204 -9999200 -9999200 -9999002 -9999004 -9999000 -9999000 -9998802 -9998804 -9998800 -9998800 -9998602 -9998604 -9998600 -9998600 -9998402 -9998404 -99...
output:
0
result:
ok answer is 0
Test #5:
score: 0
Accepted
time: 56ms
memory: 7460kb
input:
100000 3035800 3035800 3035998 3035996 -1397800 -1397800 -1397602 -1397604 9002800 9002800 9002998 9002996 -3410800 -3410800 -3410602 -3410604 2188200 2188200 2188398 2188396 -7752600 -7752600 -7752402 -7752404 819600 819600 819798 819796 -4035400 -4035400 -4035202 -4035204 658800 658800 658998 6589...
output:
1
result:
ok answer is 1
Test #6:
score: 0
Accepted
time: 110ms
memory: 15892kb
input:
100000 -500000000 -300000000 400000000 290000000 -499999000 -299999000 399999100 289999100 -499998000 -299998000 399998200 289998200 -499997000 -299997000 399997300 289997300 -499996000 -299996000 399996400 289996400 -499995000 -299995000 399995500 289995500 -499994000 -299994000 399994600 289994600...
output:
0
result:
ok answer is 0
Test #7:
score: 0
Accepted
time: 142ms
memory: 15732kb
input:
100000 -500000000 -300000000 400000000 290000000 -499999000 -299999000 400000010 290000020 -499998000 -299998000 400000020 290000040 -499997000 -299997000 400000030 290000060 -499996000 -299996000 400000040 290000080 -499995000 -299995000 400000050 290000100 -499994000 -299994000 400000060 290000120...
output:
1
result:
ok answer is 1
Test #8:
score: 0
Accepted
time: 1ms
memory: 3584kb
input:
15 0 0 1000 1000 70 70 875 875 2 2 995 995 6 6 980 980 20 20 930 950 40 40 890 910 200 200 700 700 360 390 680 680 430 400 650 600 490 495 520 505 -1000 -1000 -800 -800 -2000 -2000 -1700 -1800 -400 -400 -200 -250 -125 -140 -95 -95 -3 -3 -1 -1
output:
0
result:
ok answer is 0
Test #9:
score: 0
Accepted
time: 2ms
memory: 3584kb
input:
16 0 0 1000 1000 70 70 875 875 2 2 995 995 6 6 980 980 20 20 930 950 40 40 890 910 65 69 905 920 200 200 700 700 360 390 680 680 430 400 650 600 490 495 520 505 -1000 -1000 -800 -800 -2000 -2000 -1700 -1800 -400 -400 -200 -250 -125 -140 -95 -95 -3 -3 -1 -1
output:
1
result:
ok answer is 1
Test #10:
score: 0
Accepted
time: 45ms
memory: 7464kb
input:
99900 -5000000 3000000 -4999992 3000011 -4999985 2999985 -4999977 2999996 -4999970 2999970 -4999962 2999981 -4999955 2999955 -4999947 2999966 -4999940 2999940 -4999932 2999951 -4999925 2999925 -4999917 2999936 -4999910 2999910 -4999902 2999921 -4999895 2999895 -4999887 2999906 -4999880 2999880 -4999...
output:
0
result:
ok answer is 0
Test #11:
score: 0
Accepted
time: 64ms
memory: 7312kb
input:
99901 -5000000 3000000 -4999992 3000011 -4999985 2999985 -4999977 2999996 -4999970 2999970 -4999962 2999981 -4999955 2999955 -4999947 2999966 -4999940 2999940 -4999932 2999951 -4999925 2999925 -4999917 2999936 -4999910 2999910 -4999902 2999921 -4999895 2999895 -4999887 2999906 -4999880 2999880 -4999...
output:
1
result:
ok answer is 1
Test #12:
score: 0
Accepted
time: 76ms
memory: 7332kb
input:
99901 -5000000 3000000 -4999992 3000011 -4999985 2999985 -4999977 2999996 -4999970 2999970 -4999962 2999981 -4999955 2999955 -4999947 2999966 -4999940 2999940 -4999932 2999951 -4999925 2999925 -4999917 2999936 -4999910 2999910 -4999902 2999921 -4999895 2999895 -4999887 2999906 -4999880 2999880 -4999...
output:
1
result:
ok answer is 1
Test #13:
score: 0
Accepted
time: 54ms
memory: 7424kb
input:
99900 -5000000 3000000 -4999993 3000008 -4999985 2999997 -4999978 3000005 -4999970 2999994 -4999963 3000002 -4999955 2999991 -4999948 2999999 -4999940 2999988 -4999933 2999996 -4999925 2999985 -4999918 2999993 -4999910 2999982 -4999903 2999990 -4999895 2999979 -4999888 2999987 -4999880 2999976 -4999...
output:
0
result:
ok answer is 0
Test #14:
score: 0
Accepted
time: 56ms
memory: 7404kb
input:
99901 -3501529 2700307 -3501000 2700358 -5000000 3000000 -4999993 3000008 -4999985 2999997 -4999978 3000005 -4999970 2999994 -4999963 3000002 -4999955 2999991 -4999948 2999999 -4999940 2999988 -4999933 2999996 -4999925 2999985 -4999918 2999993 -4999910 2999982 -4999903 2999990 -4999895 2999979 -4999...
output:
1
result:
ok answer is 1
Test #15:
score: 0
Accepted
time: 68ms
memory: 7520kb
input:
99901 -4973405 2994681 -4973398 2994689 -4271765 2854353 -4271758 2854361 -4245155 2849031 -4245148 2849039 -4380800 2876160 -4380793 2876168 -3842675 2768535 -3842668 2768543 -4732460 2946492 -4732453 2946500 -3998420 2799684 -3998413 2799692 -3678485 2735697 -3678478 2735705 -4751105 2950221 -4751...
output:
1
result:
ok answer is 1
Test #16:
score: 0
Accepted
time: 1ms
memory: 3772kb
input:
11 1 1 10 6 3 19 8 24 13 4 18 9 22 7 30 13 35 3 41 8 32 11 37 18 28 35 38 41 4 5 40 20 34 17 42 28 39 16 43 25 20 26 25 31
output:
1
result:
ok answer is 1
Test #17:
score: 0
Accepted
time: 0ms
memory: 3772kb
input:
9 1 1 10 6 3 19 8 24 13 4 18 9 22 7 30 13 35 3 41 8 32 11 37 18 28 35 38 41 39 16 43 25 20 26 25 31
output:
0
result:
ok answer is 0
Test #18:
score: 0
Accepted
time: 2ms
memory: 3584kb
input:
10 1 1 10 6 3 19 8 24 13 4 18 9 22 7 30 13 35 3 41 8 32 11 37 18 28 35 38 41 39 16 43 25 20 26 25 31 11 5 51 21
output:
1
result:
ok answer is 1
Test #19:
score: 0
Accepted
time: 0ms
memory: 3688kb
input:
8 20 -105 40 -90 30 -70 50 -50 60 -140 80 -20 -10 -10 10 10 100 -130 120 -110 90 -100 140 -80 110 -40 130 -30 150 -150 190 -120
output:
0
result:
ok answer is 0
Test #20:
score: 0
Accepted
time: 2ms
memory: 3764kb
input:
9 20 -105 40 -90 30 -70 50 -50 60 -140 80 -20 -10 -10 10 10 100 -130 120 -110 15 -95 155 -45 90 -100 140 -80 110 -40 130 -30 150 -150 190 -120
output:
1
result:
ok answer is 1
Test #21:
score: 0
Accepted
time: 61ms
memory: 7480kb
input:
99600 -77794400 19794400 -77793650 19795225 1396500 -2520250 1396545 -2520188 28060080 150449752 28060137 150449814 346350 -945025 346395 -944963 -110922500 -200399375 -110922043 -200398752 -81789600 23789600 -81788850 23790425 -114069800 -202759850 -114069343 -202759227 29941570 151853633 29941627 ...
output:
0
result:
ok answer is 0
Test #22:
score: 0
Accepted
time: 76ms
memory: 7424kb
input:
99601 -129837500 -214585625 -129837043 -214585002 1151250 -2152375 1151295 -2152313 839300 -1684450 839345 -1684388 809550 -1639825 809595 -1639763 28608550 150858995 28608607 150859057 697500 -1471750 697545 -1471688 -83810300 25810300 -83809550 25811125 28976710 151133699 28976767 151133761 -12075...
output:
1
result:
ok answer is 1
Test #23:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
2 1 1 4 4 0 2 3 5
output:
1
result:
ok answer is 1
Test #24:
score: 0
Accepted
time: 2ms
memory: 3712kb
input:
2 1 1 4 3 0 0 3 4
output:
1
result:
ok answer is 1