QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#314719 | #5144. Set of Intervals | Rico64 | WA | 21ms | 3680kb | C++20 | 828b | 2024-01-26 08:19:00 | 2024-01-26 08:19:00 |
Judging History
answer
#include <iostream>
#include <algorithm>
using namespace std;
void solve() {
int n;
cin >> n;
pair<int,int> ps[n];
for (int i = 0; i < n; ++i) {
cin >> ps[i].first >> ps[i].second;
}
sort(ps, ps + n);
if (n == 1) {
cout << 1 << endl;
return;
}
long long l1 = ps[0].first;
long long l2 = ps[1].first;
sort(ps, ps + n, [](const pair<int,int>& p1, const pair<int,int>& p2) {
return p1.second > p2.second;
});
long long r1 = ps[0].second;
long long r2 = ps[1].second;
long long res = (r1 - l1 + 1) * (r1 - l1) / 2 - (l2 - l1) * (l2 - l1 - 1) / 2 - (r1 - r2) * (r1 - r2 - 1) / 2;
cout << res << endl;
}
int main() {
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: 1ms
memory: 3524kb
input:
4 1 1 1000000000 2 1 1000000000 1 1000000000 4 1 2 3 4 5 6 7 8 4 1 3 2 4 5 8 6 7
output:
1 499999999500000000 26 28
result:
ok 4 number(s): "1 499999999500000000 26 28"
Test #2:
score: 0
Accepted
time: 4ms
memory: 3572kb
input:
10000 1 778216842 910688403 1 513404058 890988011 1 1 1000000000 1 1 1000000000 1 758932694 848837772 1 516433381 715411928 1 1 1000000000 1 1 1000000000 1 1 1000000000 1 1 1000000000 1 1 1000000000 1 652548522 898071173 1 1 1000000000 1 509357508 603420032 1 1 1000000000 1 657294869 887475066 1 1 1...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok 10000 numbers
Test #3:
score: -100
Wrong Answer
time: 21ms
memory: 3680kb
input:
10000 2 427286995 863604876 582970459 874563920 2 181948005 565025282 799528580 848659925 2 1 1000000000 716032287 836380611 2 383809946 544540272 520881396 990456979 2 156308569 178412791 731100211 963724967 2 426113388 802990296 556666621 560014605 2 1 1000000000 575838571 811122140 2 255734272 64...
output:
87849603321470913 -8674795744527268 230263230414266279 75195165925255965 -147589701780048260 32977435735183263 316367547533445965 56483863859672889 35036765368929163 36132096841419954 57797703310407226 307857554310722843 261703336965133219 -92803064481147660 63833225117266922 49445284985875548 20811...
result:
wrong answer 2nd numbers differ - expected: '18821102290156188', found: '-8674795744527268'