手速选手成功混进rated only里面的前30名,但是总排名就到110+了...

A - Double Helix

  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. #define inf 0x3f3f3f3f
  4. #define il inline
  5. namespace io {
  6. #define in(a) a = read()
  7. #define out(a) write(a)
  8. #define outn(a) out(a), putchar('\n')
  9. #define I_int ll
  10. inline I_int read() {
  11. I_int x = 0, f = 1;
  12. char c = getchar();
  13. while (c < '0' || c > '9') {
  14. if (c == '-') f = -1;
  15. c = getchar();
  16. }
  17. while (c >= '0' && c <= '9') {
  18. x = x * 10 + c - '0';
  19. c = getchar();
  20. }
  21. return x * f;
  22. }
  23. char F[200];
  24. inline void write(I_int x) {
  25. if (x == 0) return (void) (putchar('0'));
  26. I_int tmp = x > 0 ? x : -x;
  27. if (x < 0) putchar('-');
  28. int cnt = 0;
  29. while (tmp > 0) {
  30. F[cnt++] = tmp % 10 + '0';
  31. tmp /= 10;
  32. }
  33. while (cnt > 0) putchar(F[--cnt]);
  34. }
  35. #undef I_int
  36. }
  37. using namespace io;
  38. using namespace std;
  39. #define N 100010
  40. char s[N];
  41. int main() {
  42. scanf("%s",s);
  43. if(s[0] == 'A') putchar('T');
  44. if(s[0] == 'T') putchar('A');
  45. if(s[0] == 'G') putchar('C');
  46. if(s[0] == 'C') putchar('G');
  47. }

B - ATCoder

  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. #define inf 0x3f3f3f3f
  4. #define il inline
  5. namespace io {
  6. #define in(a) a = read()
  7. #define out(a) write(a)
  8. #define outn(a) out(a), putchar('\n')
  9. #define I_int ll
  10. inline I_int read() {
  11. I_int x = 0, f = 1;
  12. char c = getchar();
  13. while (c < '0' || c > '9') {
  14. if (c == '-') f = -1;
  15. c = getchar();
  16. }
  17. while (c >= '0' && c <= '9') {
  18. x = x * 10 + c - '0';
  19. c = getchar();
  20. }
  21. return x * f;
  22. }
  23. char F[200];
  24. inline void write(I_int x) {
  25. if (x == 0) return (void) (putchar('0'));
  26. I_int tmp = x > 0 ? x : -x;
  27. if (x < 0) putchar('-');
  28. int cnt = 0;
  29. while (tmp > 0) {
  30. F[cnt++] = tmp % 10 + '0';
  31. tmp /= 10;
  32. }
  33. while (cnt > 0) putchar(F[--cnt]);
  34. }
  35. #undef I_int
  36. }
  37. using namespace io;
  38. using namespace std;
  39. #define N 100010
  40. char s[N];
  41. bool check(char c) {
  42. if(c == 'A') return 1;
  43. if(c == 'G') return 1;
  44. if(c == 'T') return 1;
  45. if(c == 'C') return 1;
  46. return 0;
  47. }
  48. int main() {
  49. scanf("%s",s); int cnt = 0, ans = 0, n = strlen(s);
  50. for(int i = 0; i < n; ++i) {
  51. if(check(s[i])) ++cnt;
  52. else ans = max(ans, cnt), cnt = 0;
  53. }
  54. ans = max(ans, cnt);
  55. outn(ans);
  56. }

C - GeT AC

这个C怎么比B还简单...

  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. #define inf 0x3f3f3f3f
  4. #define il inline
  5. namespace io {
  6. #define in(a) a = read()
  7. #define out(a) write(a)
  8. #define outn(a) out(a), putchar('\n')
  9. #define I_int ll
  10. inline I_int read() {
  11. I_int x = 0, f = 1;
  12. char c = getchar();
  13. while (c < '0' || c > '9') {
  14. if (c == '-') f = -1;
  15. c = getchar();
  16. }
  17. while (c >= '0' && c <= '9') {
  18. x = x * 10 + c - '0';
  19. c = getchar();
  20. }
  21. return x * f;
  22. }
  23. char F[200];
  24. inline void write(I_int x) {
  25. if (x == 0) return (void) (putchar('0'));
  26. I_int tmp = x > 0 ? x : -x;
  27. if (x < 0) putchar('-');
  28. int cnt = 0;
  29. while (tmp > 0) {
  30. F[cnt++] = tmp % 10 + '0';
  31. tmp /= 10;
  32. }
  33. while (cnt > 0) putchar(F[--cnt]);
  34. }
  35. #undef I_int
  36. }
  37. using namespace io;
  38. using namespace std;
  39. #define N 100010
  40. int n = read(), q = read();
  41. int sum[N];
  42. char s[N];
  43. int main() {
  44. scanf("%s",s+1);
  45. for(int i = 1; i <= n; ++i) {
  46. sum[i] = sum[i - 1];
  47. if(s[i]=='C'&&s[i-1]=='A') {
  48. ++sum[i];
  49. }
  50. }
  51. while(q--){
  52. int l = read(), r = read();
  53. outn(sum[r]-sum[l]);
  54. }
  55. }

D - We Like AGC

全场唯一有点意思的题了...直接考虑太麻烦了,dp一下。

\(f[i][j][a][b]\)表示位置i,i字符j,i-1字符a,i-2字符b。

利用map来简化判断过程: mp[1]='A'; mp[2]='C';mp[3]='G';mp[4]='T'

利用string重载了加法这个特性,也可以简化判断过程。

然后思考一下就会发现不合法的判定情况就6种(虽然我想+调了要半小时...),如下(a,b,c,d的位置是递增的)

  1. map<int,string>mp;
  2. bool check(int a,int b,int c, int d) {
  3. if(mp[a]+mp[c]+mp[b]=="AGC") return 0;
  4. if(mp[a]+mp[b]+mp[d]=="AGC") return 0;
  5. if(mp[a]+mp[c]+mp[d]=="AGC") return 0;
  6. if(mp[b]+mp[c]+mp[d]=="AGC") return 0;
  7. if(mp[b]+mp[d]+mp[c]=="AGC") return 0;
  8. if(mp[c]+mp[b]+mp[d]=="AGC") return 0;
  9. return 1;
  10. }

所以转移的时候再多枚举一个第i-3位的字符,就可以\(O(5^4n)\)解决这题了。注意要特判\(n\leq 2\)的情况。

  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. #define inf 0x3f3f3f3f
  4. #define il inline
  5. namespace io {
  6. #define in(a) a = read()
  7. #define out(a) write(a)
  8. #define outn(a) out(a), putchar('\n')
  9. #define I_int ll
  10. inline I_int read() {
  11. I_int x = 0, f = 1;
  12. char c = getchar();
  13. while (c < '0' || c > '9') {
  14. if (c == '-') f = -1;
  15. c = getchar();
  16. }
  17. while (c >= '0' && c <= '9') {
  18. x = x * 10 + c - '0';
  19. c = getchar();
  20. }
  21. return x * f;
  22. }
  23. char F[200];
  24. inline void write(I_int x) {
  25. if (x == 0) return (void) (putchar('0'));
  26. I_int tmp = x > 0 ? x : -x;
  27. if (x < 0) putchar('-');
  28. int cnt = 0;
  29. while (tmp > 0) {
  30. F[cnt++] = tmp % 10 + '0';
  31. tmp /= 10;
  32. }
  33. while (cnt > 0) putchar(F[--cnt]);
  34. }
  35. #undef I_int
  36. }
  37. using namespace io;
  38. using namespace std;
  39. #define N 100010
  40. const ll mod = 1e9 + 7;
  41. int n = read();
  42. ll f[N][5][5][5];
  43. /*
  44. f[i][j][a][b]位置i,字符j,i-1字符a,i-2字符b
  45. */
  46. map<int,string>mp;
  47. bool check(int a,int b,int c, int d) {
  48. if(mp[a]+mp[c]+mp[b]=="AGC") return 0;
  49. if(mp[a]+mp[b]+mp[d]=="AGC") return 0;
  50. if(mp[a]+mp[c]+mp[d]=="AGC") return 0;
  51. if(mp[b]+mp[c]+mp[d]=="AGC") return 0;
  52. if(mp[b]+mp[d]+mp[c]=="AGC") return 0;
  53. if(mp[c]+mp[b]+mp[d]=="AGC") return 0;
  54. return 1;
  55. }
  56. int main() {
  57. if(n<=2) return outn(pow(4,n)), 0;
  58. mp[0]='Q'; mp[1]='A'; mp[2]='C';mp[3]='G';mp[4]='T';
  59. f[0][0][0][0]=1;
  60. for(int i = 1; i <= n; ++i)
  61. for(int j = 1; j <= 4; ++j)
  62. for(int a = 0; a <= 4; ++a)
  63. for(int b = 0; b <= 4; ++b)
  64. for(int l = 0; l <= 4; ++l)
  65. if(check(l,b,a,j)) (f[i][j][a][b] += f[i-1][a][b][l]) %= mod;
  66. ll ans = 0;
  67. for(int i = 1; i <= 4; ++i) {
  68. for(int j = 1; j <= 4; ++j) {
  69. for(int k = 1; k <= 4; ++k) {
  70. (ans+=f[n][i][j][k])%=mod;
  71. }
  72. }
  73. }
  74. outn(ans);
  75. }

AtCoder Beginner Contest 122 解题报告的更多相关文章

  1. AtCoder Beginner Contest 146解题报告

    题目地址 https://atcoder.jp/contests/abc146/tasks 感觉没有什么有意思的题... 题解 A #include <bits/stdc++.h> usi ...

  2. Atcoder Beginner Contest 124 解题报告

    心态爆炸.本来能全做出来的.但是由于双开了Comet oj一个比赛,写了ABC就去搞那个的B题 还被搞死了. 回来写了一会D就过了.可惜比赛已经结束了.真的是作死. A - Buttons #incl ...

  3. AtCoder Beginner Contest 118 解题报告

    A - B +/- A #include <bits/stdc++.h> int main() { int a, b; std::cin >> a >> b; b ...

  4. AtCoder Beginner Contest 120 解题报告

    为啥最近都没有arc啊... A - Favorite Sound #include <algorithm> #include <iostream> #include < ...

  5. AtCoder Beginner Contest 117 解题报告

    果然abc都是手速场. 倒序开的qwq. D题因为忘记1e12二进制几位上界爆了一发. A - Entrance Examination 就是除一下就行了... 看样例猜题意系列. #include& ...

  6. AtCoder Beginner Contest 132 解题报告

    前四题都好水.后面两道题好难. C Divide the Problems #include <cstdio> #include <algorithm> using names ...

  7. AtCoder Beginner Contest 129 解题报告

    传送门 写了四个题就跑去打球了.第五题应该能肝出来的. A - Airplane #include <bits/stdc++.h> using namespace std; inline ...

  8. AtCoder Beginner Contest 127 解题报告

    传送门 非常遗憾.当天晚上错过这一场.不过感觉也会掉分的吧.后面两题偏结论题,打了的话应该想不出来. A - Ferris Wheel #include <bits/stdc++.h> u ...

  9. AtCoder Beginner Contest 126 解题报告

    突然6道题.有点慌.比赛写了五个.罚时爆炸.最后一个时间不太够+没敢写就放弃了. 两道题奇奇怪怪的WJ和20/20.今天的评测机是怎么了. A Changing a Character #includ ...

随机推荐

  1. Sharding-JDBC实践(一)简介

    转载自:ShardingSphere官网 目录 一.介绍 1. Sharding-JDBC 2. Sharding-Proxy 3. Sharding-Sidecar(TBD) 4. 混合架构 二.功 ...

  2. python:HTMLTestRunner测试报告优化

    之前的博客有介绍过python的单元测试框架unittest,基于其扩展的测试报告模块HTMLTestRunner,不过这个报告本身的界面看起来太丑... 趁着今天有时间,找了两个二次开发优化后的HT ...

  3. Feature Extractor[DenseNet]

    0.背景 随着CNN变得越来越深,人们发现会有梯度消失的现象.这个问题主要是单路径的信息和梯度的传播,其中的激活函数都是非线性的,从而特别是乘法就可以使得随着层数越深,假设将传统的神经网络的每一层看成 ...

  4. [Spark][kafka]kafka 的topic 创建和删除试验

    kafka 的topic 创建和删除试验 zookeeper和kafka 的安装,参考: http://www.cnblogs.com/caoguo/p/5958608.html 参考上述URL后,在 ...

  5. python中join()函数的使用方法

    函数:string.join() Python中有join()和os.path.join()两个函数,具体作用如下:    join():    连接字符串数组.将字符串.元组.列表中的元素以指定的字 ...

  6. [Linux]Debian 9重启DNS重置问题

    先编辑/etc/resolv.conf, 添加一个DNS, 比如114.114.114.114 然后sudo apt-get install resolvconf 然后编辑/etc/resolvcon ...

  7. C. Prefixes and Suffixes

    链接 [https://codeforces.com/contest/1092/problem/C] 题意 给你某个字符串的长度n,再给你2*n-2个前缀或者后缀 让你判断那些是前缀那些是后缀 关键是 ...

  8. 配置nginx反向代理服务器,解决浏览器跨域调用接口的限制问题

    配置nginx反向代理服务器,解决浏览器跨域调用接口的限制问题 - 大venn的博客 - CSDN博客https://blog.csdn.net/u011135260/article/details/ ...

  9. 常见的 CSRF、XSS、sql注入、DDOS流量攻击

    CSRF攻击 :跨站请求伪造攻击 ,CSRF全名是Cross-site request forgery,是一种对网站的恶意利用,CSRF比XSS更具危险性 攻击者一般会使用吸引人的图片去引导用户点击进 ...

  10. PHP PSR代码规范

    转载: https://www.awaimai.com/916.html PSR是PHP通用性框架小组 (PHP Framework Interop Group) 制定的PHP代码编写格式规范,是PH ...