> Talk is cheap
>
> Show me the code
by ferrum_cccp @ 2019-05-29 11:18:26
```cpp
#include <bits/stdc++.h>
//#include <tr1/unordered_map>
//#include"Bignum/bignum.h"
//#define lll bignum
#define ls(x) ( x << 1 )
#define rs(x) ( x << 1 | 1 )
#define mid ( (l + r) >> 1 )
#define lowbit(x) ( x & -x )
#define debug(x) (cout << "#x = " << (x) << endl)
#define Set(x, i) memset (x, i, sizeof(x))
#define R register
#define For(i, j, k) for(R int i = (j); i <= (k); ++i)
#define foR(i, j, k) for(R int i = (j); i >= (k); --i)
#define Cross(i, j, k) for(R int i = (j); i; i = (k))
using namespace std;
typedef int ll;
const ll MAXN = 1011;
const ll INF = 5e16;
ll Time;
ll n, m;
struct Node {
ll x, y;
} p[MAXN], W[MAXN];
inline double Dis ( Node a, Node b ) {
return sqrt ((a.x - b.x) *
(a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
struct Edge {
ll To, Next;
} e[MAXN * MAXN << 1];
ll cnt = 0, head[MAXN];
inline void add ( ll u, ll v ) {
e[++cnt].To = v,
e[cnt].Next = head[u], head[u] = cnt;
}
namespace IO {
inline char gc() {
static char buf[100000], *p1 = buf, *p2 = buf;
return (p1 == p2) && (p2 = (p1 = buf) +
fread (buf, 1, 100000, stdin), p1 == p2)? EOF: *p1++;
}
#define dd ch = getchar()
inline ll read() {
ll x = 0; bool f = 0; char dd;
for (; !isdigit (ch); dd) f ^= (ch == '-');
for (; isdigit (ch); dd) x = x * 10 + (ch ^ 48);
return f? -x: x;
}
#undef dd
inline void write( ll x ) {
if (x < 0) putchar ('-'), x = -x;
if (x > 9) write (x / 10); putchar (x % 10 | 48);
}
inline void wrn ( ll x ) { write (x); putchar (' '); }
inline void wln ( ll x ) { write (x); putchar ('\n'); }
inline void wlnn ( ll x, ll y ) { wrn (x), write (y); }
}
using namespace IO;
ll Vis[MAXN], Link[MAXN << 1];
inline int dfs ( ll u ) {
Cross ( i, head[u], e[i].Next )
if (!Vis[e[i].To]) {
ll v = e[i].To; Vis[v] = 1;
if (Link[v] == -1) return Link[v] = u, 1;
if (dfs (Link[v])) return Link[v] = u, 1;
} return 0;
}
inline ll Hungarian ( ll m ) {
ll res = 0;
Set (Link, -1);
For ( i, 1, m ) Set (Vis, 0), res += dfs (i);
return res;
}
int main()
{
// freopen(".in", "r", stdin);
// freopen(".out", "w", stdout);
n = read(), m = read();
For ( i, 1, n ) p[i].x = read(), p[i].y = read();
For ( i, 1, m ) W[i].x = read(), W[i].y = read();
For ( i, 1, n - 1 ) For ( j, 1, m )
if (Dis (p[i], p[i + 1]) * 2 >=
Dis (p[i], W[j]) + Dis (W[j], p[i + 1])) add (j, i);
wln (Hungarian (m) + n);
For ( i, 1, n ) {
wlnn (p[i].x, p[i].y);
if (i == n) puts ("");
else {
putchar (' ');
if (Link[i] != -1)
wlnn (W[Link[i]].x, W[Link[i]].y), putchar (' ');
}
} return 0;
}
/*
*/
```
by Cesare @ 2019-05-29 11:23:59
捞贴
by Cesare @ 2019-05-29 11:42:21
@[Cesare](/space/show?uid=104379) 打捞失败
by ycyaw @ 2019-05-29 13:00:00
@[ιχγббб](/space/show?uid=27858) 哦啊Z
by Cesare @ 2019-05-29 13:03:18