QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#48683 | #4393. Snatch Groceries | neko_nyaa# | AC ✓ | 72ms | 10376kb | C++20 | 764b | 2022-09-15 10:05:19 | 2022-09-15 10:05:22 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
bool overlap(pair<int, int> a, pair<int, int> b) {
auto [l1, r1] = a;
auto [l2, r2] = b;
if (l1 > r2) return 0;
if (l2 > r1) return 0;
return 1;
}
void solve() {
int n; cin >> n;
vector<pair<int, int>> p;
for (int i = 0; i < n; i++) {
int l, r; cin >> l >> r;
p.emplace_back(l, 0);
p.emplace_back(r, 1);
}
sort(p.begin(), p.end());
int ans = 0;
int prv = 1;
for (auto [x, c]: p) {
if (c != (prv^1)) {
cout << ans << '\n';
return;
} else {
prv ^= 1;
ans += prv;
}
}
cout << ans << '\n';
}
signed main() {
ios::sync_with_stdio(0); cin.tie(0);
int t; cin >> t;
while (t--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 72ms
memory: 10376kb
input:
5 3 1 2 3 4 5 6 3 1 2 3 4 4 5 100000 263324740 263324748 920719069 920719077 82595123 82595132 765796214 765796222 621714954 621714959 77799324 77799332 278166427 278166428 375391536 375391545 856576804 856576812 512542774 512542781 829984452 829984457 302442403 302442404 779239984 779239986 1189173...
output:
3 1 275 5575 10000
result:
ok 5 lines