Submission #412957

# Submission time Handle Problem Language Result Execution time Memory
412957 2021-05-27T20:58:40 Z Pbezz Roads (CEOI20_roads) C++14
15 / 100
20 ms 1660 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define pb push_back
#define mp make_pair
typedef pair<ll,ll> pii;
 
typedef tree<pii ,null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
const ll MAXN = 301;
const ll MOD = 1e9+7;
const ll INF = 1e6+10;

long double value(pair<pii, pii> v){

long double x1,x2,y1,y2;
x1 = v.first.first;
y1 = v.first.second;
x2 = v.second.first;
y2 = v.second.second;

y2-=y1;
x2-=x1;

x1 = x1*(y2)/x2;

return y1-x1;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	ll n,i,x1,x2,y1,y2;
	cin>>n;

	vector< pair<pii, pii> >v(n);
	for(i=0;i<n;i++){

	cin>>x1>>y1>>x2>>y2;

	v[i]={ {x1,y1}, {x2,y2} };
	}//x1=x2 e y2>y1

	if(x1==x2){//todos verticais

	for(i=0;i<n;i++){

if(v[i].second.second<v[i].first.second)swap(v[i].second.second,v[i].first.second);

	}

	sort(v.begin(),v.end());

	for(i=0;i<n-1;i++){

	cout<<v[i].second.first<<" "<<v[i].second.second<<" ";
	cout<<v[i+1].first.first<<" "<<v[i+1].first.second<<'\n';


}

	}else{

	long double k;
	vector< pair<long double, pii>>info(n);
	//info[i] = { Y ,{ X, I } };
	for(i=0;i<n;i++){//ver qual a y coordinate em x=0

	k = value(v[i]);
	//cout<<i<<" "<<k<<endl;
	info[i] = { k ,{ v[i].first.first, i } };
}

	sort(info.begin(),info.end());

	for(i=0;i<n-1;i++){

	cout<<v[ info[i].second.second ].second.first<<" "<<v[info[i].second.second ].second.second<<" ";
	cout<<v[ info[i+1].second.second ].first.first<<" "<<v[info[i+1].second.second ].first.second<<'\n';


	}


	

}






return 0;
}
# Verdict Execution time Memory Grader output
1 Failed 1 ms 204 KB Condition failed: "!Cross(S[*pi], S[*pa])"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 10 ms 972 KB Output is correct
5 Correct 19 ms 1652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 11 ms 988 KB Output is correct
5 Correct 19 ms 1660 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Failed 2 ms 328 KB Condition failed: "!Cross(S[*pi], S[*pa])"
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 10 ms 1032 KB Output is correct
5 Correct 20 ms 1604 KB Output is correct
6 Failed 1 ms 204 KB Condition failed: "pf == Sline.end() || !Cross(S[*pa], S[*pf])"
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 1 ms 204 KB Condition failed: "!Cross(S[*pi], S[*pa])"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 1 ms 308 KB Condition failed: "!Cross(S[*pi], S[*pa])"
2 Halted 0 ms 0 KB -