1 条题解
-
0
注意到完全 DAG 中 ,考虑造出 的完全 DAG 后二进制拆分。
给 数组排序,让 号点出发的路径有 条(),连边 ,一共需要 个点,至此问题得到解决。
#include <bits/stdc++.h> using namespace std; deque < pair <int,int> > q; void add(int x, int y) { q.push_back(make_pair(x, y)); } void insert(int x, int y) { q.push_front(make_pair(x ,y)); } void print() { cout << 66 << ' ' << q.size() << endl; while (!q.empty()) { cout << q.front().first << ' ' << q.front().second << endl; q.pop_front(); } } long long c[42]; int main() { int k, n; cin >> k >> n; for (int i = 0; i <= k; i++) cin >> c[i]; for (int i = k + 1; i <= 32; i++) c[i] = c[0]; for (int i = 0; i <= 32; i++) c[i] = c[i] * 1000 + i; c[0] += 100; for (int i = 34; i <= 65; i++) for (int j = i + 1; j <= 66; j++) add(i, j); sort(c, c + 33); for (int i = 0; i <= 32; i++) { long long d=c[i] / 1000; if (i) d -= c[i - 1] / 1000; for (int j = 0; j <= 31; j++) if(d & (1ll << j)) add(i + 1, 65 - j); } for (int i = 32; i >= 1; i--) for (int j = 0; j <= 32; j++) if (c[j] % 1000 == i) insert(j + 1, j + 2); print(); return 0; }
- 1
信息
- ID
- 240
- 时间
- 1000ms
- 内存
- 512MiB
- 难度
- 6
- 标签
- 递交数
- 8
- 已通过
- 4
- 上传者