# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
592146 |
2022-07-08T16:38:35 Z |
jasmin |
Roads (CEOI20_roads) |
C++14 |
|
16 ms |
1620 KB |
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int inf=1e18;
void subtask2(int n, vector<pair<pair<int,int>, pair<int,int> > >& p, vector<pair<pair<int,int>, pair<int,int> > >& old){
auto compare=[&](int i, int j){
auto a=p[i];
auto b=p[j];
if(a.first<b.first) return true;
else if(a.first>b.first) return false;
else{
if(a.second<b.second) return true;
return false;
}
};
vector<int> sorted(n);
iota(sorted.begin(), sorted.end(), 0);
sort(sorted.begin(), sorted.end(), compare);
pair<int,int> last={-inf, -inf};
for(int i=0; i<n; i++){
auto a=old[sorted[i]].first;
auto b=old[sorted[i]].second;
if(last.first!=-inf){
cout << last.first << " " << last.second << " " << a.first << " " << a.second << "\n";
}
last=b;
}
}
int length(pair<int,int> a, pair<int,int> b){
int x1=abs(a.first-b.first);
int x2=abs(a.second-b.second);
int square=x1*x1 + x2*x2;
int l=0; int r=square;
int ans=0;
while(l<=r){
int m=l+(r-l)/2;
if(m*m<=square){
ans=m;
l=m+1;
}
else{
r=m-1;
}
}
return ans;
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<pair<pair<int,int>, pair<int,int> > >p(n);
bool s2=true;
for(int i=0; i<n; i++){
cin >> p[i].first.first >> p[i].first.second;
cin >> p[i].second.first >> p[i].second.second;
if(p[i].first>p[i].second){
swap(p[i].first, p[i].second);
}
if(p[i].first.first!=p[i].second.first) s2=false;
}
if(s2){
subtask2(n, p, p);
return 0;
}
vector<pair<pair<int,int>, pair<int,int> > >p2=p;
for(int i=0; i<n; i++){
pair<int,int> a=p[i].first;
pair<int,int> b=p[i].second;
int l=length(a, b);
pair<int,int> neu;
neu.first=a.first;
neu.second=a.second+l;
p2[i].second=neu;
}
subtask2(n, p2, p);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Failed |
0 ms |
212 KB |
Condition failed: "!Cross(S[*pi], S[*pa])" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
9 ms |
980 KB |
Output is correct |
5 |
Correct |
15 ms |
1620 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
7 ms |
988 KB |
Output is correct |
5 |
Correct |
16 ms |
1600 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Failed |
1 ms |
340 KB |
Condition failed: "!Cross(S[*pi], S[*pa])" |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
7 ms |
980 KB |
Output is correct |
5 |
Correct |
14 ms |
1620 KB |
Output is correct |
6 |
Failed |
0 ms |
212 KB |
Condition failed: "!Cross(S[*pi], S[*pa])" |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Failed |
1 ms |
212 KB |
Condition failed: "!Cross(S[*pi], S[*pa])" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Failed |
0 ms |
212 KB |
Condition failed: "!Cross(S[*pi], S[*pa])" |
2 |
Halted |
0 ms |
0 KB |
- |