比赛链接:传送门

前期大顺风,2:30金区中游。后期开题乏力,掉到银尾。4:59绝杀I,但罚时太高卡在银首。


Problem A - Dogs and Cages 00:09:45 (+) Solved by Dancepted

算了半天发现就是n-1,被队友喷死,差点气哭。

Problem E - Evil Forest 00:16:54 (+) Solved by xk

xk大喊签到,就过了。

代码:

  1. #include <iostream>
  2. #include <cmath>
  3. #include <map>
  4. #include <algorithm>
  5. #include <cstdio>
  6. #include <cstring>
  7. #include <set>
  8. #include <vector>
  9. #include <string>
  10. #include <queue>
  11. #include <stack>
  12. #include <iomanip>
  13. #define fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
  14. #define N 100005
  15. #define M 100005
  16. #define INF 0x3f3f3f3f
  17. #define mk(x) (1<<x) // be conscious if mask x exceeds int
  18. #define sz(x) ((int)x.size())
  19. #define upperdiv(a,b) (a/b + (a%b>0))
  20. #define mp(a,b) make_pair(a, b)
  21. #define endl '\n'
  22. #define lowbit(x) (x&-x)
  23.  
  24. using namespace std;
  25. typedef long long ll;
  26. typedef double db;
  27.  
  28. /** fast read **/
  29. template <typename T>
  30. inline void read(T &x) {
  31. x = ; T fg = ; char ch = getchar();
  32. while (!isdigit(ch)) {
  33. if (ch == '-') fg = -;
  34. ch = getchar();
  35. }
  36. while (isdigit(ch)) x = x*+ch-'', ch = getchar();
  37. x = fg * x;
  38. }
  39. template <typename T, typename... Args>
  40. inline void read(T &x, Args &... args) { read(x), read(args...); }
  41. template <typename T>
  42. inline void write(T x) {
  43. int len = ; char c[]; if (x < ) putchar('-'), x = -x;
  44. do{++len; c[len] = x% + '';} while (x /= );
  45. for (int i = len; i >= ; i--) putchar(c[i]);
  46. }
  47. template <typename T, typename... Args>
  48. inline void write(T x, Args ... args) { write(x), write(args...); }
  49.  
  50. int main() {
  51. fast;
  52. int T, kase = ;
  53. cin >> T;
  54. while (T--) {
  55. int n;
  56. cin >> n;
  57. int ans = ;
  58. for(int i = ; i < n; i++)
  59. {
  60. int x;
  61. cin >> x;
  62. ans += x + upperdiv(x, );
  63. }
  64. cout << "Case #" << (kase++) << ": " << ans << endl;
  65. }
  66. return ;
  67. }

Problem C - Rich Game 00:32:42 (+) Solved by xk

xk又喊了一声签到!

代码:

  1. #include <iostream>
  2. #include <cmath>
  3. #include <map>
  4. #include <algorithm>
  5. #include <cstdio>
  6. #include <cstring>
  7. #include <set>
  8. #include <vector>
  9. #include <string>
  10. #include <queue>
  11. #include <stack>
  12. #include <iomanip>
  13. #define fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
  14. #define N 100005
  15. #define M 100005
  16. #define INF 0x3f3f3f3f
  17. #define mk(x) (1<<x) // be conscious if mask x exceeds int
  18. #define sz(x) ((int)x.size())
  19. #define upperdiv(a,b) (a/b + (a%b>0))
  20. #define mp(a,b) make_pair(a, b)
  21. #define endl '\n'
  22. #define lowbit(x) (x&-x)
  23.  
  24. using namespace std;
  25. typedef long long ll;
  26. typedef double db;
  27.  
  28. /** fast read **/
  29. template <typename T>
  30. inline void read(T &x) {
  31. x = ; T fg = ; char ch = getchar();
  32. while (!isdigit(ch)) {
  33. if (ch == '-') fg = -;
  34. ch = getchar();
  35. }
  36. while (isdigit(ch)) x = x*+ch-'', ch = getchar();
  37. x = fg * x;
  38. }
  39. template <typename T, typename... Args>
  40. inline void read(T &x, Args &... args) { read(x), read(args...); }
  41. template <typename T>
  42. inline void write(T x) {
  43. int len = ; char c[]; if (x < ) putchar('-'), x = -x;
  44. do{++len; c[len] = x% + '';} while (x /= );
  45. for (int i = len; i >= ; i--) putchar(c[i]);
  46. }
  47. template <typename T, typename... Args>
  48. inline void write(T x, Args ... args) { write(x), write(args...); }
  49.  
  50. int main() {
  51. fast;
  52. int T, kase = ;
  53. cin >> T;
  54. while (T--) {
  55. int x, y, k;
  56. cin >> x >> y >> k;
  57. int money = , ans = ;
  58. if(x > y) ans = k;
  59. else
  60. {
  61. for(int i = ; i < k; i++)
  62. {
  63. if(money + * x >= * y) {
  64. money += * x - * y;
  65. ans++;
  66. }
  67. else {
  68. money += * x;
  69. }
  70. }
  71. }
  72. cout << "Case #" << (kase++) << ": " << ans << endl;
  73. }
  74. return ;
  75. }

Problem K - Knightmare 00:46:33 (+) Solved by Dancepted

步数较少的时候可以往回走,把没走过的地方填上,步数增长到一定程度时,答案差不多会均匀增长。

我猜测是小数据打表,大数据是个公式之类的。

开完A趁电脑没人就打了个表,发现和我的猜测是一致的,果断交了一发就过了。

代码:

  1. #include <iostream>
  2. #include <cmath>
  3. #include <map>
  4. #include <algorithm>
  5. #include <cstdio>
  6. #include <cstring>
  7. #include <set>
  8. #include <stdio.h>
  9. #include <utility>
  10. #include <vector>
  11. #include <string>
  12. #include <queue>
  13. #include <stack>
  14. #include <iomanip>
  15. #define fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
  16. #define N 1005
  17. #define M 100005
  18. #define INF 0x3f3f3f3f
  19. #define mk(x) (1<<x) // be conscious if mask x exceeds int
  20. #define sz(x) ((int)x.size())
  21. #define upperdiv(a,b) (a/b + (a%b>0))
  22. #define mp(a,b) make_pair(a, b)
  23. #define endl '\n'
  24. #define lowbit(x) (x&-x)
  25.  
  26. using namespace std;
  27. typedef __int128 ll;
  28. typedef double db;
  29.  
  30. /** fast read **/
  31. template <typename T>
  32. inline void read(T &x) {
  33. x = ; T fg = ; char ch = getchar();
  34. while (!isdigit(ch)) {
  35. if (ch == '-') fg = -;
  36. ch = getchar();
  37. }
  38. while (isdigit(ch)) x = x*+ch-'', ch = getchar();
  39. x = fg * x;
  40. }
  41. template <typename T, typename... Args>
  42. inline void read(T &x, Args &... args) { read(x), read(args...); }
  43. template <typename T>
  44. inline void write(T x) {
  45. int len = ; char c[]; if (x < ) putchar('-'), x = -x;
  46. do{++len; c[len] = x% + '';} while (x /= );
  47. for (int i = len; i >= ; i--) putchar(c[i]);
  48. }
  49. template <typename T, typename... Args>
  50. inline void write(T x, Args ... args) { write(x), write(args...); }
  51.  
  52. const int ans[] = {, , , , , };
  53. int main() {
  54. int T; cin >> T;
  55. int kase = ;
  56. while (T--) {
  57. ll n; read(n);
  58. printf("Case #%d: ", kase++);
  59. if (n <= ) {
  60. write(ans[n]);
  61. }
  62. else {
  63. ll res = * n * n - * n + ;
  64. write(res);
  65. }
  66. putchar('\n');
  67. }
  68.  
  69. return ;
  70. }

Problem J - Subway Chasing 01:42:00 (+) Solved by xk & lh

好像是差分约束什么的。图论这种事相信队友就完了。

代码:

  1. #include <iostream>
  2. #include <cmath>
  3. #include <map>
  4. #include <algorithm>
  5. #include <cstdio>
  6. #include <cstring>
  7. #include <set>
  8. #include <vector>
  9. #include <string>
  10. #include <queue>
  11. #include <stack>
  12. #include <iomanip>
  13. #define fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
  14. #define N 100005
  15. #define M 100005
  16. #define INF 0x3f3f3f3f
  17. #define mk(x) (1<<x) // be conscious if mask x exceeds int
  18. #define sz(x) ((int)x.size())
  19. #define upperdiv(a,b) (a/b + (a%b>0))
  20. #define mp(a,b) make_pair(a, b)
  21. #define endl '\n'
  22. #define lowbit(x) (x&-x)
  23.  
  24. using namespace std;
  25. typedef long long ll;
  26. typedef double db;
  27.  
  28. /** fast read **/
  29. template <typename T>
  30. inline void read(T &x) {
  31. x = ; T fg = ; char ch = getchar();
  32. while (!isdigit(ch)) {
  33. if (ch == '-') fg = -;
  34. ch = getchar();
  35. }
  36. while (isdigit(ch)) x = x*+ch-'', ch = getchar();
  37. x = fg * x;
  38. }
  39. template <typename T, typename... Args>
  40. inline void read(T &x, Args &... args) { read(x), read(args...); }
  41. template <typename T>
  42. inline void write(T x) {
  43. int len = ; char c[]; if (x < ) putchar('-'), x = -x;
  44. do{++len; c[len] = x% + '';} while (x /= );
  45. for (int i = len; i >= ; i--) putchar(c[i]);
  46. }
  47. template <typename T, typename... Args>
  48. inline void write(T x, Args ... args) { write(x), write(args...); }
  49.  
  50. const int maxn = + ;
  51.  
  52. struct edge
  53. {
  54. int v, l;
  55. };
  56.  
  57. ll dis[maxn];
  58. int cnt[maxn];
  59. bool inq[maxn];
  60. vector<edge> g[maxn];
  61.  
  62. void addedge(int u, int v, int l)
  63. {
  64. g[u].push_back(edge{v, l});
  65. // g[v].push_back(edge{u, l});
  66. }
  67.  
  68. int n, m, x;
  69.  
  70. bool spfa()
  71. {
  72. queue<int> q;
  73. dis[] = ;
  74. q.push();
  75. cnt[] = inq[] = ;
  76. while(!q.empty())
  77. {
  78. int u = q.front();
  79. inq[u] = ;
  80. q.pop();
  81. for(auto &e : g[u])
  82. {
  83. if(dis[e.v] > dis[u] + e.l)
  84. {
  85. dis[e.v] = dis[u] + e.l;
  86.  
  87. if(!inq[e.v]) {
  88. cnt[e.v]++;
  89. if(cnt[e.v] >= n) return false;
  90. q.push(e.v);
  91. inq[e.v] = ;
  92. }
  93. }
  94. }
  95. }
  96. return true;
  97. }
  98.  
  99. int main()
  100. {
  101. fast;
  102. int T, kase = ;
  103. cin >> T;
  104. while (T--)
  105. {
  106. cin >> n >> m >> x;
  107. for(int i = ; i <= n; i++)
  108. {
  109. g[i].clear();
  110. dis[i] = 1e18;
  111. cnt[i] = inq[i] = ;
  112. }
  113. for(int i = ; i < n; i++)
  114. {
  115. addedge(i+, i, -);
  116. addedge(i, i+, 2e9);
  117. }
  118. for(int i = ; i < m; i++)
  119. {
  120. int a, b, c, d;
  121. cin >> a >> b >> c >> d;
  122. if(a == b)
  123. {
  124. if(c == d)
  125. {
  126. addedge(a, c, x);
  127. addedge(c, a, -x);
  128. }
  129. else
  130. {
  131. addedge(a, c, x - );
  132. addedge(d, a, -x - );
  133. }
  134. }
  135. else
  136. {
  137. if(c == d)
  138. {
  139. addedge(b, c, x - );
  140. addedge(c, a, -x - );
  141. }
  142. else
  143. {
  144. addedge(b, c, x - );
  145. addedge(d, a, -x - );
  146. }
  147. }
  148. }
  149. cout << "Case #" << (kase++);
  150. if(!spfa()) cout << " IMPOSSIBLE\n";
  151. else {
  152. for(int i = ; i <= n; i++)
  153. cout << ' ' << dis[i] - dis[i - ];
  154. cout << endl;
  155. }
  156. }
  157. return ;
  158. }

Problem G - Alice’s Stamps 02:24:14 (-2) Solved by Dancepted (dp)

上机的时候思路有乱,调出来之后交上去因为N开大了MLE返回CE,贡献了两发罚时。

dfs枚举当前搜索过的最右端点和剩下的k的数量,记忆化一下,状态数最多就$O(n^{2})$。

HDU的T组数据比较玄学,差点没敢交。

代码:$O(n^{2})$

  1. #include <iostream>
  2. #include <cmath>
  3. #include <map>
  4. #include <algorithm>
  5. #include <cstdio>
  6. #include <cstring>
  7. #include <set>
  8. #include <vector>
  9. #include <string>
  10. #include <queue>
  11. #include <stack>
  12. #include <iomanip>
  13. #define fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
  14. #define N 2005
  15. #define M 100005
  16. #define INF 0x3f3f3f3f
  17. #define mk(x) (1<<x)
  18. #define sz(x) ((int)x.size())
  19. #define upperdiv(a,b) (a/b + (a%b>0))
  20. #define mp(a,b) make_pair(a, b)
  21. #define endl '\n'
  22. #define lowbit(x) (x&-x)
  23.  
  24. using namespace std;
  25. typedef long long ll;
  26. typedef double db;
  27.  
  28. /** fast read **/
  29. template <typename T>
  30. inline void read(T &x) {
  31. x = ; T fg = ; char ch = getchar();
  32. while (!isdigit(ch)) {
  33. if (ch == '-') fg = -;
  34. ch = getchar();
  35. }
  36. while (isdigit(ch)) x = x*+ch-'', ch = getchar();
  37. x = fg * x;
  38. }
  39. template <typename T, typename... Args>
  40. inline void read(T &x, Args &... args) { read(x), read(args...); }
  41. template <typename T>
  42. inline void write(T x) {
  43. int len = ; char c[]; if (x < ) putchar('-'), x = -x;
  44. do{++len; c[len] = x% + '';} while (x /= );
  45. for (int i = len; i >= ; i--) putchar(c[i]);
  46. }
  47. template <typename T, typename... Args>
  48. inline void write(T x, Args ... args) { write(x), write(args...); }
  49.  
  50. struct Node{
  51. int l, r;
  52. bool operator < (const Node& x) const {
  53. if (r == x.r) {
  54. return l < x.l;
  55. }
  56. return r < x.r;
  57. }
  58. };
  59.  
  60. int n, m, k;
  61. vector<Node> ns, ns1;
  62. int ans = ;
  63. int f[N][N];
  64. int dfs(int id, int r, int cnt, int resk) {
  65. if (f[r][resk]) {
  66. return f[r][resk];
  67. }
  68. if (resk == ) {
  69. return ;
  70. }
  71. if (id >= sz(ns)) {
  72. return ;
  73. }
  74. int tmp = dfs(id+, r, cnt, resk);
  75. tmp = max(tmp, ns[id].r - max(ns[id].l-, r) + dfs(id+, ns[id].r, cnt + ns[id].r - max(ns[id].l-, r), resk-));
  76. ans = max(ans, cnt + tmp);
  77. return f[r][resk] = tmp;
  78. }
  79. bool ok[N];
  80. int l[N], r[N];
  81. int main() {
  82. int T, kase = ;
  83. cin >> T;
  84. while (T--) {
  85. ns.clear(), ns1.clear();
  86. read(n, m, k);
  87. for (int i = ; i <= m; i++) {
  88. read(l[i], r[i]);
  89. ok[i] = true;
  90. }
  91. for (int i = ; i <= m; i++) {
  92. for (int j = ; j <= m; j++) if (i != j) {
  93. if (l[i] < l[j] && r[j] <= r[i]) {
  94. ok[j] = false;
  95. }
  96. }
  97. }
  98. for (int i = ; i <= m; i++) if (ok[i]) {
  99. ns.push_back(Node{l[i], r[i]});
  100. }
  101. sort(ns.begin(), ns.end());
  102.  
  103. // init();
  104. ans = ;
  105. for (int i = ; i <= n; i++) {
  106. for (int j = ; j <= k; j++) {
  107. f[i][j] = ;
  108. }
  109. }
  110. dfs(, , , k);
  111. printf("Case #%d: %d\n", kase++, ans);
  112. }
  113. return ;
  114. }

题解的做法是一个很好写的dp:

$f_{i, j}$表示最右边的覆盖点是i的情况下,用了j个集合的最大覆盖长度。

代码:$O(n^{2})$

  1. #include <iostream>
  2. #include <cmath>
  3. #include <map>
  4. #include <algorithm>
  5. #include <cstdio>
  6. #include <cstring>
  7. #include <set>
  8. #include <vector>
  9. #include <string>
  10. #include <queue>
  11. #include <stack>
  12. #include <iomanip>
  13. #define fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
  14. #define N 2005
  15. #define M 100005
  16. #define INF 0x3f3f3f3f
  17. #define mk(x) (1<<x) // be conscious if mask x exceeds int
  18. #define sz(x) ((int)x.size())
  19. #define upperdiv(a,b) (a/b + (a%b>0))
  20. #define mp(a,b) make_pair(a, b)
  21. #define endl '\n'
  22. #define lowbit(x) (x&-x)
  23.  
  24. using namespace std;
  25. typedef long long ll;
  26. typedef double db;
  27.  
  28. /** fast read **/
  29. template <typename T>
  30. inline void read(T &x) {
  31. x = ; T fg = ; char ch = getchar();
  32. while (!isdigit(ch)) {
  33. if (ch == '-') fg = -;
  34. ch = getchar();
  35. }
  36. while (isdigit(ch)) x = x*+ch-'', ch = getchar();
  37. x = fg * x;
  38. }
  39. template <typename T, typename... Args>
  40. inline void read(T &x, Args &... args) { read(x), read(args...); }
  41. template <typename T>
  42. inline void write(T x) {
  43. int len = ; char c[]; if (x < ) putchar('-'), x = -x;
  44. do{++len; c[len] = x% + '';} while (x /= );
  45. for (int i = len; i >= ; i--) putchar(c[i]);
  46. }
  47. template <typename T, typename... Args>
  48. inline void write(T x, Args ... args) { write(x), write(args...); }
  49.  
  50. int mxr[N];
  51. int f[N][N];
  52. int main() {
  53. int T; cin >> T;
  54. for (int kase = ; kase <= T; kase++) {
  55. int n, m, k; read(n, m, k);
  56. memset(mxr, , (n+) * sizeof(int));
  57. for (int i = ; i <= n; i++) {
  58. for (int j = ; j <= k; j++) {
  59. f[i][j] = ;
  60. }
  61. }
  62. for (int i = ; i <= m; i++) {
  63. int l, r; read(l, r);
  64. mxr[l] = max(mxr[l], r);
  65. }
  66. int ans = , r = ;
  67. for (int i = ; i <= n; i++) {
  68. r = max(mxr[i], r);
  69. for (int j = ; j <= k; j++) {
  70. f[i][j] = max(f[i][j], f[i-][j]);
  71. ans = max(ans, f[i][j]);
  72. if (j+ <= k)
  73. f[r][j+] = max(f[r][j+], f[i-][j] + r - i + ),
  74. ans = max(ans, f[r][j+]);
  75. }
  76. }
  77. printf("Case #%d: %d\n", kase, ans);
  78. }
  79. return ;
  80. }

Problem I - Inkopolis 04:59:59 (-3) Solved by Dancepted & xk

中午还在看的基环树下午就用到了。

先考虑树上的情况。会影响答案的部分只有修改颜色之前的颜色$color_{pre}$,和之后的颜色$color_{now}$两种。看是否会新增、删除color region,或者合并、分割原来的color region。

再考虑环上的情况。同上。特别地:如果整个环都是同一种颜色,修改了颜色不会分割原来的color region;如果整个环除了修改的边都是$color_{now}$,则修改颜色不会合并color region。

计算节日开始前各街道的颜色,可以模仿修改的操作,一条条边加入就行了。

实现的时候先把环扣出来,统计一下环各颜色的边数量。用个map保存每个点相邻的各颜色的数量。再用map保存每条边的颜色。

然后扫一遍所有的边先计算初始情况下的region的数量sum,然后一次次修改边的颜色,更新sum就好了。

代码:O(nlogn)

  1. #include <iostream>
  2. #include <cmath>
  3. #include <map>
  4. #include <algorithm>
  5. #include <cstdio>
  6. #include <cstring>
  7. #include <set>
  8. #include <vector>
  9. #include <string>
  10. #include <queue>
  11. #include <stack>
  12. #include <iomanip>
  13. #define fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
  14. #define N 200005
  15. #define M 200005
  16. #define INF 0x3f3f3f3f
  17. #define mk(x) (1<<x) // be conscious if mask x exceeds int
  18. #define sz(x) ((int)x.size())
  19. #define upperdiv(a,b) (a/b + (a%b>0))
  20. #define mp(a,b) make_pair(a, b)
  21. #define endl '\n'
  22. #define lowbit(x) (x&-x)
  23.  
  24. using namespace std;
  25. typedef long long ll;
  26. typedef double db;
  27.  
  28. /** fast read **/
  29. template <typename T>
  30. inline void read(T &x) {
  31. x = ; T fg = ; char ch = getchar();
  32. while (!isdigit(ch)) {
  33. if (ch == '-') fg = -;
  34. ch = getchar();
  35. }
  36. while (isdigit(ch)) x = x*+ch-'', ch = getchar();
  37. x = fg * x;
  38. }
  39. template <typename T, typename... Args>
  40. inline void read(T &x, Args &... args) { read(x), read(args...); }
  41. template <typename T>
  42. inline void write(T x) {
  43. int len = ; char c[]; if (x < ) putchar('-'), x = -x;
  44. do{++len; c[len] = x% + '';} while (x /= );
  45. for (int i = len; i >= ; i--) putchar(c[i]);
  46. }
  47. template <typename T, typename... Args>
  48. inline void write(T x, Args ... args) { write(x), write(args...); }
  49.  
  50. int tot;
  51. int head[N], nxt[N<<], ver[N<<], col[N<<];
  52. void addEdge(int u, int v, int c) {
  53. nxt[tot] = head[u], ver[tot] = v, col[tot] = c, head[u] = tot++;
  54. }
  55.  
  56. int iscir[N], cirlen;
  57. bool vis[N];
  58. int getCir(int u, int fa, int& rt) {
  59. vis[u] = true;
  60. for (int i = head[u]; i != -; i = nxt[i]) {
  61. int v = ver[i];
  62. if (v == fa) continue;
  63. if (vis[v]) {
  64. rt = v;
  65. iscir[u] = ;
  66. cirlen++;
  67. return ;
  68. }
  69. else {
  70. int tmpcir = getCir(v, u, rt);
  71. if (tmpcir) {
  72. iscir[u] = tmpcir;
  73. cirlen++;
  74. return u != rt;
  75. }
  76. }
  77. }
  78. return ;
  79. }
  80.  
  81. int cnt[N];
  82. int sum;
  83. map<int, int> mp[N];
  84. map<pair<int,int>, int> uv_col;
  85.  
  86. void update(int u, int v, int ccur, bool ifprint) {
  87. if (u > v) swap(u, v);
  88. int cpre = uv_col[mp(u, v)];
  89. if (cpre == ccur) {
  90. if (ifprint)
  91. printf("%d\n", sum);
  92. return;
  93. }
  94. if (!iscir[u] || !iscir[v]) {
  95. //on tree
  96. if (mp[u][cpre] >= && mp[v][cpre] >= ) {
  97. sum++;
  98. }
  99. if (mp[u][cpre] == && mp[v][cpre] == ) {
  100. sum--;
  101. }
  102. if (mp[u][ccur] && mp[v][ccur]) {
  103. sum--;
  104. }
  105. if (!mp[u][ccur] && !mp[v][ccur]) {
  106. sum++;
  107. }
  108. }
  109. else {
  110. //on circle
  111. if (mp[u][cpre] >= && mp[v][cpre] >= ) {
  112. if (cnt[cpre] != cirlen)
  113. sum++;
  114. }
  115. if (mp[u][cpre] == && mp[v][cpre] == ) {
  116. sum--;
  117. }
  118. if (mp[u][ccur] && mp[v][ccur]) {
  119. if (cnt[ccur] != cirlen-)
  120. sum--;
  121. }
  122. if (!mp[u][ccur] && !mp[v][ccur]) {
  123. sum++;
  124. }
  125.  
  126. if (cpre != -)
  127. cnt[cpre]--;
  128. cnt[ccur]++;
  129. }
  130. uv_col[mp(u, v)] = ccur;
  131. if (cpre != -) {
  132. mp[u][cpre]--;
  133. mp[v][cpre]--;
  134. }
  135. mp[u][ccur]++;
  136. mp[v][ccur]++;
  137. if (ifprint)
  138. printf("%d\n", sum);
  139. }
  140.  
  141. int main() {
  142. int T;
  143. cin >> T;
  144. for (int kase = ; kase <= T; kase++) {
  145. int n, m; read(n, m);
  146. // init
  147. uv_col.clear();
  148. for (int i = ; i <= n; i++) {
  149. mp[i].clear();
  150. }
  151. tot = ;
  152. memset(head, -, (n+) * sizeof(int));
  153.  
  154. // input and count colors on every edge
  155. for (int i = ; i <= n; i++) {
  156. int u, v, c; read(u, v, c);
  157. addEdge(u, v, c);
  158. addEdge(v, u, c);
  159. if (u > v)
  160. swap(u, v);
  161. uv_col[mp(u, v)] = -;
  162. // mp[u][c]++; mp[v][c]++;
  163. }
  164. // get circle
  165. int rt = -;
  166. memset(vis, false, (n+) * sizeof(bool));
  167. memset(iscir, , (n+) * sizeof(int));
  168. cirlen = ;
  169. getCir(, -, rt);
  170. // count colors on circle
  171. memset(cnt, , (n+) * sizeof(int));
  172. sum = ;
  173. for (int i = ; i < n; i++) {
  174. int u = ver[i<<], v = ver[i<<|], ccur = col[i<<];
  175. update(u, v, ccur, false);
  176. }
  177.  
  178. printf("Case #%d:\n", kase);
  179. for (int i = ; i <= m; i++) {
  180. int u, v, ccur; read(u, v, ccur);
  181. update(u, v, ccur, true);
  182. }
  183. }
  184. return ;
  185. }
  186. /*
  187. 11111
  188. 5 10
  189. 1 5 1
  190. 2 5 1
  191. 3 5 1
  192. 4 5 1
  193. 1 2 1
  194. 1 2 1
  195.  
  196. 2
  197. 4 4
  198. 1 2 1
  199. 2 3 1
  200. 3 4 1
  201. 4 1 1
  202. 1 2 2
  203. 3 4 2
  204. 2 3 2
  205. 4 1 4
  206. 4 3
  207. 4 2 4
  208. 2 3 3
  209. 3 4 2
  210. 1 4 1
  211. 3 4 2
  212. 2 3 4
  213. 3 4 3
  214. */

总结:

本场能绝杀还是有点运气成分在的,而且现场赛的话最后几分钟可能就交不上题了也可能。不过绝杀也不影响苟在银牌,问题不大。

然后最近的几场好像都是我在贡献罚时,感觉码力出现了一些小小的问题。这两天要小心一点。

然后还有两周可能就要退役了,模拟赛还没有进过金区感觉很难受啊,打成这个样子还怎么冲金啊qaq。

模拟赛小结:2017 China Collegiate Programming Contest Final (CCPC-Final 2017)的更多相关文章

  1. The 2017 China Collegiate Programming Contest, Hangzhou Site Solution

    A: Super_palindrome 题面:给出一个字符串,求改变最少的字符个数使得这个串所有长度为奇数的子串都是回文串 思路:显然,这个字符串肯定要改成所有奇数位相同并且所有偶数位相同 那统计一下 ...

  2. 2017 China Collegiate Programming Contest Final (CCPC 2017)

    题解右转队伍wiki https://acm.ecnu.edu.cn/wiki/index.php?title=2017_China_Collegiate_Programming_Contest_Fi ...

  3. The 2015 China Collegiate Programming Contest A. Secrete Master Plan hdu5540

    Secrete Master Plan Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Othe ...

  4. The 2015 China Collegiate Programming Contest Game Rooms

    Game Rooms Time Limit: 4000/4000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) Submi ...

  5. 2016 China Collegiate Programming Contest Final

    2016 China Collegiate Programming Contest Final Table of Contents 2016 China Collegiate Programming ...

  6. 2018 China Collegiate Programming Contest Final (CCPC-Final 2018)-K - Mr. Panda and Kakin-中国剩余定理+同余定理

    2018 China Collegiate Programming Contest Final (CCPC-Final 2018)-K - Mr. Panda and Kakin-中国剩余定理+同余定 ...

  7. 模拟赛小结:The 2019 China Collegiate Programming Contest Harbin Site

    比赛链接:传送门 上半场5题,下半场疯狂挂机,然后又是差一题金,万年银首也太难受了. (每次银首都会想起前队友的灵魂拷问:你们队练习的时候进金区的次数多不多啊?) Problem J. Justify ...

  8. 模拟赛小结:2018 China Collegiate Programming Contest Final (CCPC-Final 2018)

    比赛链接:传送门 跌跌撞撞6题摸银. 封榜后两题,把手上的题做完了还算舒服.就是罚时有点高. 开出了一道奇奇怪怪的题(K),然后ccpcf银应该比区域赛银要难吧,反正很开心qwq. Problem A ...

  9. The 2019 China Collegiate Programming Contest Harbin Site F. Fixing Banners

    链接: https://codeforces.com/gym/102394/problem/F 题意: Harbin, whose name was originally a Manchu word ...

随机推荐

  1. axios的中文使用文档

    axios 基于promise用于浏览器和node.js的http客户端 原文链接 lewis1990@amoy 特点 支持浏览器和node.js 支持promise 能拦截请求和响应 能转换请求和响 ...

  2. Angular引入第三方库

    原文已经写的很好了.原文链接: https://blog.csdn.net/yuzhiqiang_1993/article/details/71215232 加上2点给自己用,引入bootstrap样 ...

  3. C语言基础:内置函数的调用

    #include<stdio.h>#include<math.h>#include<stdlib.h>#include<ctype.h>#include ...

  4. shell一文入门通

    版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明.本文链接:https://blog.csdn.net/hebtu666/article/deta ...

  5. js动态修改浏览器title

    script标签依据浏览框的失焦获焦进行函数操作(操作简单放到HTML文件下的head标签下就可以) <script> window.onfocus = function () { doc ...

  6. HTML页面左上角图标

    显示网页左上角标志图标 <link rel="shortcut icon"type="image/x-icon"href="images/fav ...

  7. Python3学习笔记-更新中

    1.Python概况 2.Anaconda安装及使用 3.Pycharm安装及使用 4.Hello World!!! 5.数据类型及类型转换 6.分支结构 7.循环语句 8.异常

  8. 2019CCPC-江西省赛 -A Cotree (树形DP,求树上一点到其他点的距离之和)

    我是傻逼我是傻逼 #include<bits/stdc++.h> using namespace std; const int maxn=4e5+50; typedef long long ...

  9. python中迭代器和生成器的详细解释

    https://www.cnblogs.com/wilber2013/p/4652531.html

  10. tomcat启动报ClassNotFound

    排除本来就缺少该类的原因,经过自己经验和网上查的资料,解决方式如下: jar包冲突(关闭其他项目) eclipse的java版本不对,点击项目,右键properties在project facets, ...