QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#367582 | #2365. Flight Collision | kevinyang# | WA | 38ms | 12780kb | C++17 | 1.4kb | 2024-03-26 08:12:28 | 2024-03-26 08:12:29 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
signed main(){
cin.tie(nullptr)->sync_with_stdio(false);
int n;
cin >> n;
vector<pair<int,int>>arr(n+1);
for(int i = 1; i<=n; i++){
cin >> arr[i].first >> arr[i].second;
}
set<pair<double,pii>>s;
set<int>vals;
for(int i = 1; i<=n; i++){
vals.insert(i);
}
for(int i = 2; i<=n; i++){
if(arr[i-1].second > arr[i].second){
int v = (arr[i-1].second - arr[i].second);
double t = (double)arr[i].first - arr[i-1].first;
t/=v;
s.insert({t,{i-1,i}});
}
}
while(s.size()){
auto res = *s.begin();
s.erase(s.begin());
int x = res.second.first;
int y = res.second.second;
if(vals.find(x) == vals.end() || vals.find(y) == vals.end()){
continue;
}
vals.erase(x);
vals.erase(y);
auto l = vals.lower_bound(x);
if(l==vals.begin())continue;
l--;
auto r = vals.upper_bound(y);
if(r==vals.end())continue;
int lx = *l;
int rx = *r;
if(arr[lx].second > arr[rx].second){
int v = (arr[lx].second - arr[rx].second);
double t = double(arr[rx].first - arr[lx].first);
t/=v;
s.insert({t,{lx,rx}});
}
}
cout << vals.size() << '\n';
vector<int>vec;
for(int nxt: vals){
vec.push_back(nxt);
}
for(int i = 0; i<vec.size(); i++){
cout << vec[i];
if(i+1<vec.size())cout << ' ';
}
cout << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3548kb
input:
1 -4 13
output:
1 1
result:
ok 2 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 3520kb
input:
5 1 1000000000 2 1000000000 3 -1000000000 4 -1000000000 5 -1000000000
output:
1 5
result:
ok 2 lines
Test #3:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
3 -1000000000 1 999999999 0 1000000000 0
output:
1 3
result:
ok 2 lines
Test #4:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
2 5 4 10 5
output:
2 1 2
result:
ok 2 lines
Test #5:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
9 10 10 20 7 30 5 40 0 42 0 50 -1 60 -2 70 -10 80 -12
output:
1 1
result:
ok 2 lines
Test #6:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
5 10 0 20 0 30 1 40 0 50 0
output:
3 1 2 5
result:
ok 2 lines
Test #7:
score: 0
Accepted
time: 29ms
memory: 10560kb
input:
98765 0 -48539 1 -48539 2 -48539 3 -48539 4 -48539 5 -48539 6 -48539 7 -48539 8 -48539 9 -48539 10 -48539 11 -48539 12 -48539 13 -48539 14 -48539 15 -48539 16 -48539 17 -48539 18 -48539 19 -48539 20 -48539 21 -48539 22 -48539 23 -48539 24 -48539 25 -48539 26 -48539 27 -48539 28 -48539 29 -48539 30 -...
output:
98765 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 10...
result:
ok 2 lines
Test #8:
score: 0
Accepted
time: 37ms
memory: 12724kb
input:
99999 -999999396 999999395 -999971669 999999396 -999971668 -999999396 -999961260 999999396 -999961259 -999999396 -999907239 999999396 -999907238 -999999396 -999754561 999999396 -999754560 -999999396 -999662011 999999396 -999662010 -999999396 -999651505 999999396 -999651504 -999999396 -999619141 9999...
output:
1 99999
result:
ok 2 lines
Test #9:
score: -100
Wrong Answer
time: 38ms
memory: 12780kb
input:
99999 -999999244 999999243 -999956299 999999244 -999956298 -999999244 -999945616 999999244 -999945615 -999999244 -999944410 999999244 -999944409 -999999244 -999891030 999999244 -999891029 -999999244 -999862261 999999244 -999862260 -999999244 -999835376 999999244 -999835375 -999999244 -999705681 9999...
output:
1 99999
result:
wrong answer 2nd lines differ - expected: '1', found: '99999'