A - Beginning

这个年份恐怕需要+2

  1. #include <bits/stdc++.h>
  2. #define fi first
  3. #define se second
  4. #define pii pair<int,int>
  5. #define mp make_pair
  6. #define pb push_back
  7. #define space putchar(' ')
  8. #define enter putchar('\n')
  9. #define MAXN 80005
  10. #define eps 1e-10
  11. //#define ivorysi
  12. using namespace std;
  13. typedef long long int64;
  14. typedef double db;
  15. template<class T>
  16. void read(T &res) {
  17. res = 0;T f = 1;char c = getchar();
  18. while(c < '0' || c > '9') {
  19. if(c == '-') f = -1;
  20. c = getchar();
  21. }
  22. while(c >= '0' && c <= '9') {
  23. res = res * 10 + c - '0';
  24. c = getchar();
  25. }
  26. res *= f;
  27. }
  28. template<class T>
  29. void out(T x) {
  30. if(x < 0) {x = -x;putchar('-');}
  31. if(x >= 10) {
  32. out(x / 10);
  33. }
  34. putchar('0' + x % 10);
  35. }
  36. int num[10];
  37. void Solve() {
  38. for(int i = 1 ; i <= 4 ; ++i) read(num[i]);
  39. sort(num + 1,num + 5);
  40. if(num[1] == 1 && num[2] == 4 && num[3] == 7 && num[4] == 9) {puts("YES");}
  41. else puts("NO");
  42. }
  43. int main() {
  44. #ifdef ivorysi
  45. freopen("f1.in","r",stdin);
  46. #endif
  47. Solve();
  48. }

B - KEYENCE String

……

  1. #include <bits/stdc++.h>
  2. #define fi first
  3. #define se second
  4. #define pii pair<int,int>
  5. #define mp make_pair
  6. #define pb push_back
  7. #define space putchar(' ')
  8. #define enter putchar('\n')
  9. #define MAXN 80005
  10. #define eps 1e-10
  11. //#define ivorysi
  12. using namespace std;
  13. typedef long long int64;
  14. typedef double db;
  15. template<class T>
  16. void read(T &res) {
  17. res = 0;T f = 1;char c = getchar();
  18. while(c < '0' || c > '9') {
  19. if(c == '-') f = -1;
  20. c = getchar();
  21. }
  22. while(c >= '0' && c <= '9') {
  23. res = res * 10 + c - '0';
  24. c = getchar();
  25. }
  26. res *= f;
  27. }
  28. template<class T>
  29. void out(T x) {
  30. if(x < 0) {x = -x;putchar('-');}
  31. if(x >= 10) {
  32. out(x / 10);
  33. }
  34. putchar('0' + x % 10);
  35. }
  36. string s;
  37. string tar = "keyence";
  38. void Solve() {
  39. cin >> s;
  40. int p = 0;
  41. while(s[p] == tar[p]) ++p;
  42. int q = 0;
  43. while(s[s.length() - 1 - q] == tar[tar.length() - 1 - q]) ++q;
  44. if(p + q >= tar.length()) puts("YES");
  45. else puts("NO");
  46. }
  47. int main() {
  48. #ifdef ivorysi
  49. freopen("f1.in","r",stdin);
  50. #endif
  51. Solve();
  52. }

C - Exam and Wizard

就是先用一遍A的总和恢复出B,如果不足就是-1,然后贪心每次恢复最少可以回到原来的大小

  1. #include <bits/stdc++.h>
  2. #define fi first
  3. #define se second
  4. #define pii pair<int,int>
  5. #define mp make_pair
  6. #define pb push_back
  7. #define space putchar(' ')
  8. #define enter putchar('\n')
  9. #define MAXN 100005
  10. #define eps 1e-10
  11. //#define ivorysi
  12. using namespace std;
  13. typedef long long int64;
  14. typedef double db;
  15. template<class T>
  16. void read(T &res) {
  17. res = 0;T f = 1;char c = getchar();
  18. while(c < '0' || c > '9') {
  19. if(c == '-') f = -1;
  20. c = getchar();
  21. }
  22. while(c >= '0' && c <= '9') {
  23. res = res * 10 + c - '0';
  24. c = getchar();
  25. }
  26. res *= f;
  27. }
  28. template<class T>
  29. void out(T x) {
  30. if(x < 0) {x = -x;putchar('-');}
  31. if(x >= 10) {
  32. out(x / 10);
  33. }
  34. putchar('0' + x % 10);
  35. }
  36. int N;
  37. int64 A[MAXN],B[MAXN],all,C[MAXN];
  38. multiset<int64> S;
  39. void Solve() {
  40. read(N);
  41. for(int i = 1 ; i <= N ; ++i) {
  42. read(A[i]);all += A[i];
  43. }
  44. for(int i = 1 ; i <= N ; ++i) {
  45. read(B[i]);all -= B[i];
  46. if(A[i] - B[i] >= 0) S.insert(A[i] - B[i]);
  47. }
  48. if(all < 0) {puts("-1");return;}
  49. int cnt = 0;
  50. while(!S.empty()) {
  51. int64 p = *S.begin();
  52. S.erase(S.begin());
  53. if(all >= p) {all -= p;++cnt;}
  54. else break;
  55. }
  56. out(N - cnt);enter;
  57. }
  58. int main() {
  59. #ifdef ivorysi
  60. freopen("f1.in","r",stdin);
  61. #endif
  62. Solve();
  63. }

D - Double Landscape

感觉这题so interesting 啊,还可以往高维拓展

从大到小往里面塞数,记录一下每次能用的行和列,如果这个数必须在某一行或某一列,两个都固定就乘上1,一个固定,比如行固定,就乘上能用的列数

如果这个数位置没被固定,就是乘上当前能用的行列数的乘积,减去比它大的数

为什么呢。。因为一个数能填的位置,要么和前面比它大的数都没有交集,要么前面比它大的数能填的集合是它的一个真子集

  1. #include <bits/stdc++.h>
  2. #define fi first
  3. #define se second
  4. #define pii pair<int,int>
  5. #define mp make_pair
  6. #define pb push_back
  7. #define space putchar(' ')
  8. #define enter putchar('\n')
  9. #define MAXN 1005
  10. #define eps 1e-10
  11. //#define ivorysi
  12. using namespace std;
  13. typedef long long int64;
  14. typedef double db;
  15. template<class T>
  16. void read(T &res) {
  17. res = 0;T f = 1;char c = getchar();
  18. while(c < '0' || c > '9') {
  19. if(c == '-') f = -1;
  20. c = getchar();
  21. }
  22. while(c >= '0' && c <= '9') {
  23. res = res * 10 + c - '0';
  24. c = getchar();
  25. }
  26. res *= f;
  27. }
  28. template<class T>
  29. void out(T x) {
  30. if(x < 0) {x = -x;putchar('-');}
  31. if(x >= 10) {
  32. out(x / 10);
  33. }
  34. putchar('0' + x % 10);
  35. }
  36. const int MOD = 1000000007;
  37. int N,M;
  38. bool col[MAXN * MAXN],row[MAXN * MAXN];
  39. int inc(int a,int b) {
  40. return a + b >= MOD ? a + b - MOD : a + b;
  41. }
  42. int mul(int a,int b) {
  43. return 1LL * a * b % MOD;
  44. }
  45. void Solve() {
  46. read(N);read(M);
  47. int a;
  48. for(int i = 1 ; i <= N ; ++i) {
  49. read(a);
  50. if(row[a]) {puts("0");return;}
  51. row[a] = 1;
  52. }
  53. for(int i = 1 ; i <= M ; ++i) {
  54. read(a);
  55. if(col[a]) {puts("0");return;}
  56. col[a] = 1;
  57. }
  58. int ans = 1;
  59. int c = 0,r = 0;
  60. for(int i = N * M ; i >= 1 ; --i) {
  61. int tc = c,tr = r;
  62. if(col[i]) {tc = 1;++c;}
  63. if(row[i]) {tr = 1;++r;}
  64. if(col[i] || row[i]) ans = mul(ans,tc * tr);
  65. else ans = mul(ans,tc * tr - (N * M - i));
  66. }
  67. out(ans);enter;
  68. }
  69. int main() {
  70. #ifdef ivorysi
  71. freopen("f1.in","r",stdin);
  72. #endif
  73. Solve();
  74. }

E - Connecting Cities

外国人真是瞧不起中国人的数据结构水平

随手写了个线段树就过了

就是拆式子,分\(-i * D + A_i\)和\(i * D + A_i\)

然后跑prim,两个线段树取最小的就行

  1. #include <bits/stdc++.h>
  2. #define fi first
  3. #define se second
  4. #define pii pair<int,int>
  5. #define mp make_pair
  6. #define pb push_back
  7. #define space putchar(' ')
  8. #define enter putchar('\n')
  9. #define MAXN 200005
  10. #define eps 1e-10
  11. //#define ivorysi
  12. using namespace std;
  13. typedef long long int64;
  14. typedef double db;
  15. template<class T>
  16. void read(T &res) {
  17. res = 0;T f = 1;char c = getchar();
  18. while(c < '0' || c > '9') {
  19. if(c == '-') f = -1;
  20. c = getchar();
  21. }
  22. while(c >= '0' && c <= '9') {
  23. res = res * 10 + c - '0';
  24. c = getchar();
  25. }
  26. res *= f;
  27. }
  28. template<class T>
  29. void out(T x) {
  30. if(x < 0) {x = -x;putchar('-');}
  31. if(x >= 10) {
  32. out(x / 10);
  33. }
  34. putchar('0' + x % 10);
  35. }
  36. int N;int64 D;
  37. int64 A[MAXN];
  38. struct seg_tr {
  39. struct node {
  40. int L,R;
  41. int64 cov;
  42. pair<int64,int> val[2];
  43. }tr[MAXN * 4];
  44. void update(int u) {
  45. tr[u].val[1] = mp(1e16,0);
  46. if(tr[u].L != tr[u].R) {
  47. tr[u].val[0] = min(tr[u << 1].val[0],tr[u << 1 | 1].val[0]);
  48. tr[u].val[1] = min(tr[u << 1].val[1],tr[u << 1 | 1].val[1]);
  49. }
  50. tr[u].val[1] = min(tr[u].val[1],mp(tr[u].cov + tr[u].val[0].fi,tr[u].val[0].se));
  51. }
  52. void build(int u,int l,int r,int on) {
  53. tr[u].L = l;tr[u].R = r;tr[u].cov = 1e16;
  54. if(l == r) {
  55. tr[u].val[0] = mp(A[l] + on * l * D,l);
  56. update(u);
  57. return;
  58. }
  59. int mid = (l + r) >> 1;
  60. build(u << 1,l,mid,on);build(u << 1 | 1,mid + 1,r,on);
  61. update(u);
  62. }
  63. void Change(int u,int l,int r,int64 v) {
  64. if(l > r) return;
  65. if(tr[u].L == l && tr[u].R == r) {
  66. tr[u].cov = min(tr[u].cov,v);
  67. update(u);
  68. return;
  69. }
  70. int mid = (tr[u].L + tr[u].R) >> 1;
  71. if(r <= mid) Change(u << 1,l,r,v);
  72. else if(l > mid) Change(u << 1 | 1,l,r,v);
  73. else {Change(u << 1,l,mid,v);Change(u << 1 | 1,mid + 1,r,v);}
  74. update(u);
  75. }
  76. void Change_pos(int u,int p) {
  77. if(tr[u].L == tr[u].R) {
  78. tr[u].val[0] = mp(1e16,tr[u].L);
  79. update(u);return;
  80. }
  81. int mid = (tr[u].L + tr[u].R) >> 1;
  82. if(p <= mid) Change_pos(u << 1,p);
  83. else Change_pos(u << 1 | 1,p);
  84. update(u);
  85. }
  86. }s[2];
  87. void Solve() {
  88. read(N);read(D);
  89. for(int i = 1 ; i <= N ; ++i) read(A[i]);
  90. s[0].build(1,1,N,1);
  91. s[1].build(1,1,N,-1);
  92. s[0].Change_pos(1,1);s[1].Change_pos(1,1);
  93. s[0].Change(1,2,N,A[1] - D);
  94. int cnt = N - 1;
  95. int64 ans = 0;
  96. while(cnt--) {
  97. pair<int64,int> t[2];
  98. t[0] = s[0].tr[1].val[1],t[1] = s[1].tr[1].val[1];
  99. if(t[0] > t[1]) swap(t[0],t[1]);
  100. ans += t[0].fi;
  101. int u = t[0].se;
  102. s[0].Change_pos(1,u);s[1].Change_pos(1,u);
  103. s[1].Change(1,1,u - 1,1LL * u * D + A[u]);
  104. s[0].Change(1,u + 1,N,-1LL * u * D + A[u]);
  105. }
  106. out(ans);enter;
  107. }
  108. int main() {
  109. #ifdef ivorysi
  110. freopen("f1.in","r",stdin);
  111. #endif
  112. Solve();
  113. }

F - Paper Cutting

怎么又是计数转期望……输了……水平不行,从前遇见期望只会转计数。。。直到atc用一堆计数转期望把我吊着打

就是考虑一个左下角为\((i,j)\)的方形,当这个点作为左下角后,每切一刀都会被统计一次,为了方便我们姑且只讨论\(i > 0\)且\(j > 0\)的情况

这个矩形第一次存在的概率是

\(\frac{\binom{K}{2}}{\binom{N}{2}}\)

就是考虑选\(i,j\)(无序)我们需要它是\(\binom{N}{2}\)中\(\binom{K}{2}\)对中的一个

之后被再次算的概率是,就是,我又拿了一个,左下角为\(i,j\)的就又被算了一次

\(\frac{\binom{K}{3}}{\binom{N}{3}}\cdot \frac{1}{3}\)我需要最后一个选的点在最后,这样的概率有\(\frac{1}{3}\)

这样的点得集合有\(N - 2\)种,所以最后的期望是

\(\frac{\binom{K}{2}}{\binom{N}{2}} + \frac{\binom{K}{3}}{\binom{N}{3}} \cdot \frac{1}{3} \cdot (N - 2)\)

对于边上的点和角上的一个点也是同理的

  1. #include <bits/stdc++.h>
  2. #define fi first
  3. #define se second
  4. #define pii pair<int,int>
  5. #define mp make_pair
  6. #define pb push_back
  7. #define space putchar(' ')
  8. #define enter putchar('\n')
  9. #define MAXN 20000005
  10. #define eps 1e-10
  11. //#define ivorysi
  12. using namespace std;
  13. typedef long long int64;
  14. typedef double db;
  15. template<class T>
  16. void read(T &res) {
  17. res = 0;T f = 1;char c = getchar();
  18. while(c < '0' || c > '9') {
  19. if(c == '-') f = -1;
  20. c = getchar();
  21. }
  22. while(c >= '0' && c <= '9') {
  23. res = res * 10 + c - '0';
  24. c = getchar();
  25. }
  26. res *= f;
  27. }
  28. template<class T>
  29. void out(T x) {
  30. if(x < 0) {x = -x;putchar('-');}
  31. if(x >= 10) {
  32. out(x / 10);
  33. }
  34. putchar('0' + x % 10);
  35. }
  36. const int MOD = 1000000007;
  37. int H,W,K,N;
  38. int C[2][4],inv[4];
  39. int inc(int a,int b) {
  40. return a + b >= MOD ? a + b - MOD : a + b;
  41. }
  42. int mul(int a,int b) {
  43. return 1LL * a * b % MOD;
  44. }
  45. void update(int &x,int y) {
  46. x = inc(x,y);
  47. }
  48. int fpow(int x,int c) {
  49. int res = 1,t = x;
  50. while(c) {
  51. if(c & 1) res = mul(res,t);
  52. t = mul(t,t);
  53. c >>= 1;
  54. }
  55. return res;
  56. }
  57. void Solve() {
  58. read(H);read(W);read(K);
  59. N = H + W;
  60. inv[1] = 1;inv[2] = (MOD + 1) / 2;inv[3] = (MOD + 1) / 3;
  61. C[0][0] = C[1][0] = 1;
  62. for(int i = 1 ; i <= 3 ; ++i) {
  63. C[0][i] = mul(mul(C[0][i - 1],inv[i]),K - i + 1);
  64. C[1][i] = mul(mul(C[1][i - 1],inv[i]),N - i + 1);
  65. }
  66. int ans = K;
  67. int t1 = mul(K,fpow(N,MOD - 2)),t2 = mul(C[0][2],fpow(C[1][2],MOD - 2)),t3 = mul(C[0][3],fpow(C[1][3],MOD - 2));
  68. int s = inc(t1,mul(mul(t2,inv[2]),N - 1));
  69. update(ans,mul(s,H + W));
  70. s = inc(t2,mul(mul(t3,inv[3]),N - 2));
  71. update(ans,mul(s,1LL * H * W % MOD));
  72. for(int i = N ; i >= N - K + 1; --i) {
  73. ans = mul(ans,i);
  74. }
  75. out(ans);enter;
  76. }
  77. int main() {
  78. #ifdef ivorysi
  79. freopen("f1.in","r",stdin);
  80. #endif
  81. Solve();
  82. }

【AtCoder】KEYENCE Programming Contest 2019的更多相关文章

  1. 【AtCoder】AISing Programming Contest 2019

    本来以为是1199rated的..仔细一看发现是1999,所以就做了一下 这场涨分很轻松啊...为啥又没打 等pkuwc考完我一定打一场atcoder(咕咕咕,咕咕咕,咕咕咕咕咕咕咕~) 但是其实我思 ...

  2. 【AtCoder】Yahoo Programming Contest 2019

    A - Anti-Adjacency K <= (N + 1) / 2 #include <bits/stdc++.h> #define fi first #define se se ...

  3. 【AtCoder】Tenka1 Programmer Contest 2019

    Tenka1 Programmer Contest 2019 C - Stones 题面大意:有一个01序列,改变一个位置上的值花费1,问变成没有0在1右边的序列花费最少多少 直接枚举前i个都变成0即 ...

  4. 【AtCoder】M-SOLUTIONS Programming Contest

    M-SOLUTIONS Programming Contest A - Sum of Interior Angles #include <bits/stdc++.h> #define fi ...

  5. 【AtCoder】Dwango Programming Contest V题解

    A - Thumbnail 题意简述:给出N个数,找出N个数中和这N个数平均值绝对值最小的数 根据题意写代码即可= = #include <bits/stdc++.h> #define f ...

  6. KEYENCE Programming Contest 2019 自闭记

    A:签到. #include<iostream> #include<cstdio> #include<cstdlib> #include<cmath> ...

  7. KEYENCE Programming Contest 2019 Solution

    A - Beginning 签到. #include <bits/stdc++.h> using namespace std; int main() { ]; while (scanf(& ...

  8. 【AtCoder】Mujin Programming Challenge 2017

    Mujin Programming Challenge 2017 A - Robot Racing 如果每个数都是一个一个间隔开的,那么答案是\(n!\) 考虑把一个数挪到1,第二个数挪到3,以此类推 ...

  9. 【AtCoder】Tenka1 Programmer Contest

    C - 4/N 列出个方程枚举解一下 #include <bits/stdc++.h> #define fi first #define se second #define pii pai ...

随机推荐

  1. 16. Spring boot 错误页面

      默认效果:1).浏览器,返回一个默认的错误页面 1.1 请求头 1.2返回结果 2).如果是其他客户端,默认响应一个json数据 2.1请求头 2.2返回结果 { "timestamp& ...

  2. geeksforgeeks-Array-Rotate and delete

    As usual Babul is again back with his problem and now with numbers. He thought of an array of number ...

  3. [转]C++11的enum class & enum struct和enum

    1. 旧版enum存在的问题 问题 描述 1 向整形的隐式转换(Implicit conversion to an integer) 2 无法指定底层所使用的数据类型(Inability to spe ...

  4. Web下文件上传下载的路径问题

    工程结构

  5. CentOS6.5运行yum报错:No module named yum

    公司测试机环境不知道给我卸了什么包,导致yum运行报错状况: 报错情况: There was a problem importing one of the Python modulesrequired ...

  6. saltstack文件模块的replace操作简化

    代码已经过测试 import re import mmap import os import shutil old_text='test' new_text='text' path=r'C:\User ...

  7. eclipse引入系统类库

    引入系统类库1.第一步:项目,右键,build path,remove报错的类库 2.第二步:项目,右键,build path→Add Library→JRE System Library,Next3 ...

  8. oracle 命令行

    背景 看到当初竟然记录了命令行,想想自己用了多久才知道了命令行,好像有几年了吧.当时还记得买了两本oracle9的管理书籍,就跟见了九阴真经一样,从头到尾熟悉了好几遍,不过也大部分忘了交给老师了.以下 ...

  9. pl sql 存储过程 执行sql 锁死状态

    背景 这是在一个不知如何表达的项目中,我在这个项目中做的就是不知如何表达的事情.只是想着技术,到是通过这个项目把存储过程基本能用的都用了,oracle开发的技术我感觉基本都全活了.别人没搞定的我搞定了 ...

  10. centos系统初始化脚本

    #!/bin/bash #检测是否为root用户 ];then echo "Must be root can do this." exit fi #检测网络 echo " ...