题意:http://mp.weixin.QQ.com/s/ZKQI6_9XpsPRycHwzTu5Sw
题解:http://mp.weixin.qq.com/s/nHw70ZSuh_FvWNRgOhH6Xw
补充:构图可以参考Havel定理,暴力简单~
#include<bits/stdc++.h>using namespace std;int main() { int k, deg[101]; cin >> k; if (k % 2 == 0) { puts("NO"); } else if (k == 1) { puts("YES/n2 1/n1 2"); } else { int n = (k + 2) * 2; int m = n * k / 2; printf("YES/n%d %d/n", n, m); int u0 = 1, u1 = n / 2; int cnt = (m - 1) / 2; int u, v, i = 1; fill(deg + 1, deg + 1 + n / 2, k); deg[n / 2]--; bool flag = true; while (i <= cnt) { if (flag) { u = u0++; v = u0; while (deg[u]--) { printf("%d %d/n", u, v); printf("%d %d/n", u + n / 2, v + n / 2); deg[v++]--; i++; } } else { u = u1--; v = u1; while (deg[u]--) { printf("%d %d/n", u, v); printf("%d %d/n", u + n / 2, v + n / 2); deg[v--]--; i++; } } flag = !flag; } printf("%d %d/n", n / 2, n); } return 0;}
新闻热点
疑难解答