Water The Garden

  1. #pragma comment(linker, "/STACK:102400000,102400000")
  2. #include<stdio.h>
  3. #include<string.h>
  4. #include<stdlib.h>
  5. #include<vector>
  6. #include<algorithm>
  7. #include<iostream>
  8. #include<map>
  9. #include<queue>
  10. #include<stack>
  11. #include<string>
  12. #include<functional>
  13. #include<math.h>
  14. //#include<bits/stdc++.h>
  15. using namespace std;
  16. typedef long long lint;
  17. typedef vector<int> VI;
  18. typedef pair<int, int> PII;
  19. typedef queue<int> QI;
  20.  
  21. void makedata() {
  22. freopen("input.txt", "w", stdout);
  23. fclose(stdout);
  24. }
  25.  
  26. int x[];
  27.  
  28. int main() {
  29. #ifndef ONLINE_JUDGE
  30. freopen("input.txt", "r", stdin);
  31. #endif
  32. //makedata();
  33. std::ios::sync_with_stdio(), cin.tie();
  34. int n, k, t;
  35. cin >> t;
  36. while (t--) {
  37. cin >> n >> k;
  38. int ans = ;
  39. for (int i = ; i < k; i++) cin >> x[i];
  40. ans = max(ans, x[]);
  41. ans = max(ans, n - x[k - ] + );
  42. for (int i = ; i < k; i++) ans = max(ans, (x[i] - x[i - ] + ) / );
  43. cout << ans << endl;
  44. }
  45. return ;
  46. }

Tea Queue

  1. #pragma comment(linker, "/STACK:102400000,102400000")
  2. #include<stdio.h>
  3. #include<string.h>
  4. #include<stdlib.h>
  5. #include<vector>
  6. #include<algorithm>
  7. #include<iostream>
  8. #include<map>
  9. #include<queue>
  10. #include<stack>
  11. #include<string>
  12. #include<functional>
  13. #include<math.h>
  14. //#include<bits/stdc++.h>
  15. using namespace std;
  16. typedef long long lint;
  17. typedef vector<int> VI;
  18. typedef pair<int, int> PII;
  19. typedef queue<int> QI;
  20.  
  21. void makedata() {
  22. freopen("input.txt", "w", stdout);
  23. fclose(stdout);
  24. }
  25.  
  26. int l[], r[];
  27.  
  28. int main() {
  29. #ifndef ONLINE_JUDGE
  30. freopen("input.txt", "r", stdin);
  31. #endif
  32. //makedata();
  33. std::ios::sync_with_stdio(), cin.tie();
  34. int n, t;
  35. cin >> t;
  36. while (t--) {
  37. cin >> n;
  38. for (int i = ; i < n; i++) cin >> l[i] >> r[i];
  39. int time = ;
  40. for (int i = ; i < n; i++) {
  41. if (time < l[i]) time = l[i];
  42. if (time > r[i]) {
  43. cout << << ' ';
  44. continue;
  45. }
  46. cout << time << ' ';
  47. time++;
  48. }
  49. cout << endl;
  50. }
  51. return ;
  52. }

Swap Adjacent Elements

显然一段1+0子段是可以变换为任意顺序的,而各个1+0中间单独存在的0必须满足a[i]=i时才能完成排序。对于某一段1+0子段,假设对应区间为a[i]~a[j]由于它无法与其他子段发生交换,所以a[i]~a[j]中的数字必须由i~j组成。

  1. #pragma comment(linker, "/STACK:102400000,102400000")
  2. #include<stdio.h>
  3. #include<string.h>
  4. #include<stdlib.h>
  5. #include<vector>
  6. #include<algorithm>
  7. #include<iostream>
  8. #include<map>
  9. #include<queue>
  10. #include<stack>
  11. #include<string>
  12. #include<functional>
  13. #include<math.h>
  14. //#include<bits/stdc++.h>
  15. using namespace std;
  16. typedef long long lint;
  17. typedef vector<int> VI;
  18. typedef pair<int, int> PII;
  19. typedef queue<int> QI;
  20.  
  21. void makedata() {
  22. freopen("input.txt", "w", stdout);
  23. fclose(stdout);
  24. }
  25.  
  26. int a[], p[], b[];
  27. bool f[];
  28.  
  29. int main() {
  30. #ifndef ONLINE_JUDGE
  31. freopen("input.txt", "r", stdin);
  32. #endif
  33. //makedata();
  34. std::ios::sync_with_stdio(), cin.tie();
  35. int n;
  36. cin >> n;
  37. for (int i = ; i <= n; i++) {
  38. cin >> a[i];
  39. p[a[i]] = i;
  40. }
  41. char ch;
  42. for (int i = ; i < n; i++) {
  43. cin >> ch;
  44. b[i] = ch - '';
  45. }
  46. b[n] = ;
  47. bool ok = true;
  48. int ptr = ;
  49. while (ptr <= n) {
  50. if (b[ptr] == ) {
  51. if (a[ptr] != ptr) ok = false;
  52. ptr++;
  53. } else {
  54. int l = ptr;
  55. while (b[ptr] == ) ptr++;
  56. int r = ptr;
  57. for (int i = l; i <= r; i++) f[i] = false;
  58. for (int i = l; i <= r; i++) f[a[i]] = true;
  59. for (int i = l; i <= r; i++) if (!f[i]) ok = false;
  60. ptr++;
  61. }
  62. }
  63. if (ok) cout << "YES" << endl;
  64. else cout << "NO" << endl;
  65. return ;
  66. }

Tanks

如果所有的水箱中水量加起来不到v,则方案不存在。

首先选出若干个水箱,他们当前的水量加起来与v对k取余相同,若选不出来,则方案不存在。

对于选出的水箱,首先把这部分水箱中的水集中在一起,然后把其余的水箱中的水集中在一起,然后再舀回若干次k即可。

代码鸽了。

Connected Components

观察一下这个数据,其实挺搞笑的。对于小数据,怎么搞都可以。对于n和m都是20w的大数据,其答案肯定是199990+和几个一位数组成。

对于大小是S1和S2的两个强联通分量,其中的不直连关系至少要有S1*S2个。对于给定条件,每个点都缺少若干条边,其中有一个缺少的边数量最少的点,设为r,r缺边数量设为p。p能有多少呢?如果p能上万,那有缺边现象的点就不会超过20个。所以p估计也就是个四五百顶天了,那么最大的一个强联通分量就已经直接预订了这(n-四五百)这么多的点。

对于剩下的点,先不考虑外面,把他们内部的强连通分量分别算出来,然后对于每个强联通分量,如果其中一个点有连向外部的边,那么它属于最大的强联通分量的一部分,否则就是一个独立的真强联通分量。

代码鸽了

SUM and REPLACE

List of  Integers

[Codeforces]Educational Codeforces Round 37 (Rated for Div. 2)的更多相关文章

  1. Educational Codeforces Round 37 (Rated for Div. 2)C. Swap Adjacent Elements (思维,前缀和)

    Educational Codeforces Round 37 (Rated for Div. 2)C. Swap Adjacent Elements time limit per test 1 se ...

  2. Educational Codeforces Round 37 (Rated for Div. 2) 920E E. Connected Components?

    题 OvO http://codeforces.com/contest/920/problem/E 解 模拟一遍…… 1.首先把所有数放到一个集合 s 中,并创建一个队列 que 2.然后每次随便取一 ...

  3. Educational Codeforces Round 37 (Rated for Div. 2)

    我的代码应该不会被hack,立个flag A. Water The Garden time limit per test 1 second memory limit per test 256 mega ...

  4. Educational Codeforces Round 37 (Rated for Div. 2) G

    G. List Of Integers time limit per test 5 seconds memory limit per test 256 megabytes input standard ...

  5. Educational Codeforces Round 37 (Rated for Div. 2) E. Connected Components? 图论

    E. Connected Components? You are given an undirected graph consisting of n vertices and edges. Inste ...

  6. Educational Codeforces Round 72 (Rated for Div. 2)-D. Coloring Edges-拓扑排序

    Educational Codeforces Round 72 (Rated for Div. 2)-D. Coloring Edges-拓扑排序 [Problem Description] ​ 给你 ...

  7. Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship

    Problem   Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...

  8. Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems(动态规划+矩阵快速幂)

    Problem   Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec P ...

  9. Educational Codeforces Round 43 (Rated for Div. 2)

    Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include< ...

随机推荐

  1. 身份认证防止重放攻击的challenge-response方法

    或者叫询问-应答机制. 基于挑战/应答(Challenge/Response)方式的身份认证系统就是每次认证时认证服务器端都给客户端发送一个不同的"挑战"字串,客户端程序收到这个& ...

  2. C# 网页内容获取

    private string GetGeneralContent(string strUrl) { string strMsg = string.Empty; try { WebRequest req ...

  3. CorelDRAW2019新耀发布会,报名即可领红包!

    ​30年时光荏苒!眨眼风惊雨过. 在1989年的春天,CorelDRAW 1.0正式发布,一经面世就掀起了图形设计行业革命浪潮,这个图形工具不仅给设计师提供了矢量图像.页面设计,更能应用于网站制作.位 ...

  4. https://blog.csdn.net/cddcj/article/details/52193932

    https://blog.csdn.net/cddcj/article/details/52193932 兼容性

  5. 通过分析反汇编还原 C 语言 if…else 结构

    让我们从反汇编的角度去分析并还原 C 语言的 if - else 结构,首先我们不看源代码,我们用 OllyDBG 载入 PE 文件,定位到 main 函数领空,如下图所示. 在图示中,我已经做好了关 ...

  6. JVM 性能调优监控工具 jps、jstack、jmap、jhat、jstat、hprof 使用详解

    转自:  https://my.oschina.net/feichexia/blog/196575 摘要: JDK本身提供了很多方便的JVM性能调优监控工具,除了集成式的VisualVM和jConso ...

  7. Java基本排序算法

    转载来自:https://www.jianshu.com/p/5e171281a387 一遍记住Java常用的八种排序算法与代码实现   1.直接插入排序 经常碰到这样一类排序问题:把新的数据插入到已 ...

  8. Cleaning

    Cleaning Time limit : 2sec / Memory limit : 256MB Score : 700 points Problem Statement There is a tr ...

  9. java陷阱之Array.asList

    List<Integer> numbers= Arrays.asList(new Integer[] {1,2,3}); numbers.add(3); 运行这段代码会抛出 java.la ...

  10. 2017年JavaScript框架---Top5

    前言 个人观点,供您参考 观点源自作者的使用经验和日常研究 排名基于框架的受欢迎度, 语法结构, 易用性等特性 希望大家能够基于此视频找到最适合自己的框架 下面介绍的都是严格的前端框架和库 前言 To ...