#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <list>
#include <iomanip>
#include <stdlib.h>
#include <time.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define REP(i,a,b) for(ll i=a; i<b; i++)
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define ff first
#define ss second
#define whole(x) x.begin(),x.end()
#define DEBUG(i) cout<<"Pedro Is The Master "<<i<<endl
#define INF 5000000000000000000LL
template<class A=ll>
void Out(vector<A> a) {REP(i,0,a.size()) {cout<<a[i]<<" ";} cout<<endl;}
template<class A=ll>
void In(vector<A> &a, ll N) {A cur; REP(i,0,N) {cin>>cur; a.pb(cur);}}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
ll N; vector<pl> s; cin>>N; pl cur;
REP(i,0,2LL*N) {cin>>cur.ff>>cur.ss; s.pb(cur);}
vector<pl> old_s=s;
ll A = s[1].ss-s[0].ss; ll B = s[1].ff-s[0].ff;
if(B!=0LL)
{
REP(i,0,2LL*N)
{
cur.ff = B*s[i].ff+A*s[i].ss;
cur.ss = -A*s[i].ff+B*s[i].ss;
s[i]=cur;
}
REP(i,0,2*N)
{
swap(s[i].ff,s[i].ss);
}
}
vector<bool> swapped; REP(i,0,N) {swapped.pb(false);}
REP(i,0,N)
{
if(s[2*i].ss>s[2*i+1].ss) {swapped[i]=true;swap(s[2*i],s[2*i+1]);}
}
vector<vector<ll> > TO;
vector<ll> xx; REP(i,0,4) {xx.pb(0LL);}
REP(i,0,N)
{
xx[0]=s[2*i].ff; xx[1]=s[2*i].ss; xx[2]=s[2*i+1].ss; xx[3]=i;
TO.pb(xx);
}
sort(whole(TO));
REP(i,0,N-1)
{
cur.ff=TO[i][3]; cur.ss=TO[i+1][3];
if(!swapped[cur.ff]) {cur.ff=2*cur.ff+1;} else {cur.ff=2*cur.ff;}
if(!swapped[cur.ss]) {cur.ss=2*cur.ss;} else {cur.ss=2*cur.ss+1;}
cout<<old_s[cur.ff].ff<<" "<<old_s[cur.ff].ss<<" "<<old_s[cur.ss].ff<<" "<<old_s[cur.ss].ss<<endl;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Failed |
1 ms |
384 KB |
Condition failed: "pf == Sline.end() || !Cross(S[*pi], S[*pf])" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
512 KB |
Output is correct |
4 |
Correct |
35 ms |
2420 KB |
Output is correct |
5 |
Correct |
79 ms |
4464 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
512 KB |
Output is correct |
4 |
Correct |
35 ms |
2420 KB |
Output is correct |
5 |
Correct |
79 ms |
4464 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
4 ms |
512 KB |
Output is correct |
9 |
Correct |
42 ms |
2428 KB |
Output is correct |
10 |
Correct |
376 ms |
19552 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
512 KB |
Output is correct |
4 |
Correct |
46 ms |
2420 KB |
Output is correct |
5 |
Correct |
72 ms |
4464 KB |
Output is correct |
6 |
Failed |
1 ms |
384 KB |
Condition failed: "pf == Sline.end() || !Cross(S[*pa], S[*pf])" |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Failed |
1 ms |
384 KB |
Condition failed: "pf == Sline.end() || !Cross(S[*pi], S[*pf])" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Failed |
1 ms |
384 KB |
Condition failed: "pf == Sline.end() || !Cross(S[*pi], S[*pf])" |
2 |
Halted |
0 ms |
0 KB |
- |