# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
292932 | arnold518 | Roads (CEOI20_roads) | C++14 | 240 ms | 22112 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 1e5;
struct Point
{
ll x, y;
};
struct Line
{
Point p, q;
};
Point operator + (const Point &p, const Point &q) { return {p.x+q.x, p.y+q.y}; }
Point operator - (const Point &p, const Point &q) { return {p.x-q.x, p.y-q.y}; }
ll dot(const Point &p, const Point &q) { return p.x*q.x+p.y*q.y; }
bool operator < (const Point &p, const Point &q)
{
if(p.x==q.x) return p.y<q.y;
return p.x<q.x;
}
bool operator > (const Point &p, const Point &q)
{
if(p.x==q.x) return p.y>q.y;
return p.x>q.x;
}
int N;
Line A[MAXN+10];
map<ll, vector<Line>> M;
int main()
{
scanf("%d", &N);
for(int i=1; i<=N; i++) scanf("%lld%lld%lld%lld", &A[i].p.x, &A[i].p.y, &A[i].q.x, &A[i].q.y);
Point L=A[1].p-A[1].q;
swap(L.x, L.y); L.x*=-1;
for(int i=1; i<=N; i++) M[dot(A[i].p, L)].push_back(A[i]);
vector<Line> ans;
for(auto &it : M)
{
vector<Line> &V=it.second;
for(auto &jt : V) if(jt.p>jt.q) swap(jt.p, jt.q);
sort(V.begin(), V.end(), [&](const Line &pp, const Line &qq) { return pp.p<qq.p; });
for(int i=0; i+1<V.size(); i++) ans.push_back({V[i].q, V[i+1].p});
}
for(auto it=M.begin(); next(it)!=M.end(); it++) ans.push_back({it->second[0].p, next(it)->second[0].p});
for(auto it : ans) printf("%lld %lld %lld %lld\n", it.p.x, it.p.y, it.q.x, it.q.y);
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |