This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |