A

  1. #include <bits/stdc++.h>
  2. #define PI acos(-1.0)
  3. #define mem(a,b) memset((a),b,sizeof(a))
  4. #define TS printf("!!!\n")
  5. #define pb push_back
  6. #define inf 1e9
  7. //std::ios::sync_with_stdio(false);
  8. using namespace std;
  9. //priority_queue<int,vector<int>,greater<int>> que; get min
  10. const double eps = 1.0e-8;
  11. typedef pair<int, int> pairint;
  12. typedef long long ll;
  13. typedef unsigned long long ull;
  14. const int maxn = 3e7 + ;
  15. const int maxm = ;
  16. const int turn[][] = {{, }, { -, }, {, }, {, -}};
  17. //priority_queue<int, vector<int>, less<int>> que;
  18. //next_permutation
  19. ll mod = 1e9 + ;
  20. string ans;
  21. int n;
  22. string a;
  23. int flag;
  24. bool ok(char x)
  25. {
  26. if (x == 'a' || x == 'e' || x == 'i' || x == 'o' || x == 'u' || x == 'y')
  27. {
  28. return true;
  29. }
  30. return false;
  31. }
  32. int main()
  33. {
  34. cin >> n >> a;
  35. flag = ;
  36. for (int i = ; i < n; i++)
  37. {
  38. if (flag)
  39. {
  40. if (ok(a[i]))
  41. {
  42. continue;
  43. }
  44. else
  45. {
  46. ans += a[i];
  47. flag = ;
  48. }
  49. }
  50. else
  51. {
  52. if (ok(a[i]))
  53. {
  54. flag = ;
  55. ans += a[i];
  56. }
  57. else
  58. {
  59. ans += a[i];
  60. flag = ;
  61. }
  62. }
  63. }
  64. cout << ans << endl;
  65. return ;
  66. }

B

  1. #include <bits/stdc++.h>
  2. #define PI acos(-1.0)
  3. #define mem(a,b) memset((a),b,sizeof(a))
  4. #define TS printf("!!!\n")
  5. #define pb push_back
  6. #define inf 1e9
  7. //std::ios::sync_with_stdio(false);
  8. using namespace std;
  9. //priority_queue<int,vector<int>,greater<int>> que; get min
  10. const double eps = 1.0e-8;
  11. typedef pair<int, int> pairint;
  12. typedef long long ll;
  13. typedef unsigned long long ull;
  14. const int maxn = 3e7 + ;
  15. const int maxm = ;
  16. const int turn[][] = {{, }, { -, }, {, }, {, -}};
  17. //priority_queue<int, vector<int>, less<int>> que;
  18. //next_permutation
  19. ll mod = 1e9 + ;
  20. int number[];
  21. int anser = ;
  22. int main()
  23. {
  24. int n;
  25. cin >> n;
  26. for (int i = ; i <= n; i++)
  27. {
  28. int cur;
  29. cin >> cur;
  30. number[cur] = ;
  31. }
  32. for (int i = ; i <= ; i++)
  33. {
  34. if (number[i])
  35. {
  36. anser = max(anser, i - );
  37. }
  38. }
  39. for (int i = ; i >= ; i--)
  40. {
  41. if (number[i])
  42. {
  43. anser = max(anser, - i);
  44. }
  45. }
  46. cout << anser << endl;
  47. return ;
  48. }

C

N*N的方格里 每个方格可以填0或者1 要求每个M*M的小方格里面必须要有一个0

题目给你一个数 问你有没有一对 N,M使之成立

总共有N^2个方格 因为每个M*M的小方格里面需要有一个0 所以每行和每列最少都需要N/M个0 总共就是(N/M)*(N/M)个0

所以答案就是N^2-(N/M)^2个 利用立方差公式可以分解为 (N+(N/M)*(N-(N/M)=ANS 也就是分解质因数 复杂度T*SQRT X

每次遇到一个N M都要检测是否符合条件

  1. #include <bits/stdc++.h>
  2. #define PI acos(-1.0)
  3. #define mem(a,b) memset((a),b,sizeof(a))
  4. #define TS printf("!!!\n")
  5. #define pb push_back
  6. #define inf 1e9
  7. //std::ios::sync_with_stdio(false);
  8. using namespace std;
  9. //priority_queue<int,vector<int>,greater<int>> que; get min
  10. const double eps = 1.0e-10;
  11. const double EPS = 1.0e-4;
  12. typedef pair<int, int> pairint;
  13. typedef long long ll;
  14. typedef unsigned long long ull;
  15. //const int maxn = 3e5 + 10;
  16. const int maxm = ;
  17. const int turn[][] = {{, }, { -, }, {, }, {, -}};
  18. //priority_queue<int, vector<int>, less<int>> que;
  19. //next_permutation
  20. int main()
  21. {
  22. int n;
  23. cin >> n;
  24. while (n--)
  25. {
  26. int flag = ;
  27. int x;
  28. cin >> x;
  29. if (x == )
  30. {
  31. cout << << " " << << endl;
  32. continue;
  33. }
  34. for (int i = ; i <= ((int)sqrt(x) + ) && (!flag); i++)
  35. {
  36. if (x % i == )
  37. {
  38. int chu;
  39. int beichu;
  40. int a;
  41. a = x / i;
  42. chu = abs(i - a) / ;
  43. if (chu == )
  44. {
  45. continue;
  46. }
  47. beichu = min(i, a) + chu;
  48. int m;
  49. m = beichu / chu;
  50. if (beichu * beichu - (beichu / m) * (beichu / m) == x)
  51. {
  52. cout << beichu << " " << m << endl;
  53. flag = ;
  54. }
  55. //break;
  56. }
  57. }
  58. if (!flag)
  59. {
  60. cout << - << endl;
  61. }
  62. }
  63. }

D

给你N个点 每个点可以都办足球比赛 票价为Ai 同时有M条路(不保证图联通)每条路有COST

问你在城市i的球迷想看球需要的最少的钱(往返加球票钱)

用floyd肯定不行 需要建一个超级源点 然后上堆优化的迪杰斯特拉跑一边 超级源点与原来每个点之间连的边的COST为其票价

  1. #include <bits/stdc++.h>
  2. #define PI acos(-1.0)
  3. #define mem(a,b) memset((a),b,sizeof(a))
  4. #define TS printf("!!!\n")
  5. #define pb push_back
  6. #define inf 1e9
  7. //std::ios::sync_with_stdio(false);
  8. using namespace std;
  9. //priority_queue<int,vector<int>,greater<int>> que; get min
  10. const double eps = 1.0e-10;
  11. const double EPS = 1.0e-4;
  12. typedef pair<int, int> pairint;
  13. typedef long long ll;
  14. typedef unsigned long long ull;
  15. //const int maxn = 3e5 + 10;
  16. const int maxm = ;
  17. const int turn[][] = {{, }, { -, }, {, }, {, -}};
  18. //priority_queue<int, vector<int>, less<int>> que;
  19. //next_permutation
  20. int n, m;
  21. priority_queue<pair<ll, int> > que;
  22. vector<pair<int, ll> > gra[];
  23. ll sdis[];
  24. int visit[];
  25. int main()
  26. {
  27. for (int i = ; i <= ; i++)
  28. {
  29. sdis[i] = 1e18;
  30. }
  31. cin >> n >> m;
  32. int from, to;
  33. ll cost;
  34. for (int i = ; i <= m; i++)
  35. {
  36. scanf("%d %d %lld", &from, &to, &cost);
  37. cost *= 2LL;
  38. gra[from].pb(make_pair(to, cost));
  39. gra[to].pb(make_pair(from, cost));
  40. }
  41. for (int i = ; i <= n; i++)
  42. {
  43. scanf("%lld", &cost);
  44. gra[].pb(make_pair(i, cost));
  45. }
  46. que.push({, });
  47. while (!que.empty())
  48. {
  49. int now = que.top().second;
  50. que.pop();
  51. if (visit[now])
  52. {
  53. continue;
  54. }
  55. visit[now] = ;
  56. int len = gra[now].size();
  57. for (int i = ; i < len; i++)
  58. {
  59. to = gra[now][i].first;
  60. ll value = gra[now][i].second;
  61. if (!visit[to] && sdis[to] > sdis[now] + value)
  62. {
  63. sdis[to] = sdis[now] + value;
  64. que.push({ -sdis[to], to});
  65. }
  66. }
  67. }
  68. for (int i = ; i <= n; i++)
  69. {
  70. cout << sdis[i] << " ";
  71. }
  72. cout << endl;
  73. }

Codeforces 938 正方形方格最多0/1 足球赛dijkstra建图的更多相关文章

  1. 【转】Codeforces Round #406 (Div. 1) B. Legacy 线段树建图&&最短路

    B. Legacy 题目连接: http://codeforces.com/contest/786/problem/B Description Rick and his co-workers have ...

  2. Educational Codeforces Round 25 E. Minimal Labels 拓扑排序+逆向建图

    E. Minimal Labels time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  3. Codeforces Round #406 (Div. 1) B. Legacy 线段树建图跑最短路

    B. Legacy 题目连接: http://codeforces.com/contest/786/problem/B Description Rick and his co-workers have ...

  4. hdu4106 区间k覆盖问题(连续m个数,最多选k个数) 最小费用最大流 建图巧妙

    /** 题目:hdu4106 区间k覆盖问题(连续m个数,最多选k个数) 最小费用最大流 建图巧妙 链接:http://acm.hdu.edu.cn/showproblem.php?pid=4106 ...

  5. Codeforces 杂题集 2.0

      记录一些没有写在其他随笔中的 Codeforces 杂题, 以 Problemset 题号排序   1326D2 - Prefix-Suffix Palindrome (Hard version) ...

  6. Codeforces Round #523 (Div. 2) E. Politics(最小费+思维建图)

    https://codeforces.com/contest/1061/problem/E 题意 有n个点(<=500),标记第i个点的代价a[i],然后分别在这n个点建两棵树,对于每颗树的每个 ...

  7. CodeForces 786B Legacy(线段树优化建图+最短路)

    [题目链接] http://codeforces.com/problemset/problem/786/B [题目大意] 给出一些星球,现在有一些传送枪,可以从一个星球到另一个星球, 从一个星球到另一 ...

  8. Codeforces Round #545 (Div. 2) E 强连通块 + dag上求最大路径 + 将状态看成点建图

    https://codeforces.com/contest/1138/problem/E 题意 有n个城市(1e5),有m条单向边(1e5),每一周有d天(50),对于每个城市假如在某一天为1表示这 ...

  9. [Codeforces 1197E]Culture Code(线段树优化建图+DAG上最短路)

    [Codeforces 1197E]Culture Code(线段树优化建图+DAG上最短路) 题面 有n个空心物品,每个物品有外部体积\(out_i\)和内部体积\(in_i\),如果\(in_i& ...

随机推荐

  1. Python 写 ACM 题目的一些技巧

    目录 输入输出 input() 输入 split() 用于输入 strip() 输入清理 print() 输入 sort 排序 输入输出 input() 输入 Python3 中 input() 函数 ...

  2. 用Vue来实现音乐播放器(四十):歌单详情页布局以及Vuex实现路由数据通讯

    1.歌单详情页是推荐页面的二级路由页面 将推荐页面歌单的数据传到歌曲详情页面  利用vuex 1.首先在state下定义一个歌单对象 disc{} 2.在mutaions-types中  定义一个别名 ...

  3. The file is inaccessible to Server.

    ArcGIS Unable to Start serviceserver安装后,启动服务失败,报错信息如下:Unable to Start service. Error (Server object  ...

  4. python 接口测试时,后端报错no String-argument constructor/factory method

    解决方法: 1.先将字典转化为序列化的数据类型 data = {"pageNo":0,"pageSize":10,"shopId":15,& ...

  5. 用JS实现移动的窗口

    https://blog.csdn.net/iteye_21064/article/details/81496640 用JS实现移动的窗口 2007年09月06日 23:23:00 阅读数:3 很简单 ...

  6. Flink容错机制

    Flink的Fault Tolerance,是在在Chandy Lamport Algorithm的基础上扩展实现了一套分布式Checkpointing机制,这个机制在论文"Lightwei ...

  7. springboot使用MockMvc测试controller

    通常,在我们平时开发项目时,如果想要输入URL对Controller进行测试,在代码编辑之后,需要重启服务器,建立http client进行测试.这样会使得测试变得很麻烦,比如,启动速度慢,测试验证不 ...

  8. Linux 命令 - man 查看命令的文档

    man 命令是 Linux 中最常用的命令,碰到任何让你疑惑的命令,都可以 man 一下来查看详情.不只是 shell 命令,C 语言库函数和系统调用等内容也可以通过 man 命令查看. man 命令 ...

  9. springMVC+Spring+Mybatis+Redis

    SPRINGMVC+MYBATIS+SPRING+REDIS 只作参考,以防忘记使用! mybatis的配置文件: <?xml version="1.0" encoding= ...

  10. spring(二) JDBC

    一.配置 bean.xml , 链接数据库. c3p0数据库连接池 <?xml version="1.0" encoding="UTF-8"?> & ...