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

A - Double Helix

#include <bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define il inline namespace io { #define in(a) a = read()
#define out(a) write(a)
#define outn(a) out(a), putchar('\n') #define I_int ll
inline I_int read() {
I_int x = 0, f = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-') f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
x = x * 10 + c - '0';
c = getchar();
}
return x * f;
}
char F[200];
inline void write(I_int x) {
if (x == 0) return (void) (putchar('0'));
I_int tmp = x > 0 ? x : -x;
if (x < 0) putchar('-');
int cnt = 0;
while (tmp > 0) {
F[cnt++] = tmp % 10 + '0';
tmp /= 10;
}
while (cnt > 0) putchar(F[--cnt]);
}
#undef I_int }
using namespace io; using namespace std; #define N 100010 char s[N]; int main() {
scanf("%s",s);
if(s[0] == 'A') putchar('T');
if(s[0] == 'T') putchar('A');
if(s[0] == 'G') putchar('C');
if(s[0] == 'C') putchar('G');
}

B - ATCoder

#include <bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define il inline namespace io { #define in(a) a = read()
#define out(a) write(a)
#define outn(a) out(a), putchar('\n') #define I_int ll
inline I_int read() {
I_int x = 0, f = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-') f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
x = x * 10 + c - '0';
c = getchar();
}
return x * f;
}
char F[200];
inline void write(I_int x) {
if (x == 0) return (void) (putchar('0'));
I_int tmp = x > 0 ? x : -x;
if (x < 0) putchar('-');
int cnt = 0;
while (tmp > 0) {
F[cnt++] = tmp % 10 + '0';
tmp /= 10;
}
while (cnt > 0) putchar(F[--cnt]);
}
#undef I_int }
using namespace io; using namespace std; #define N 100010 char s[N]; bool check(char c) {
if(c == 'A') return 1;
if(c == 'G') return 1;
if(c == 'T') return 1;
if(c == 'C') return 1;
return 0;
} int main() {
scanf("%s",s); int cnt = 0, ans = 0, n = strlen(s);
for(int i = 0; i < n; ++i) {
if(check(s[i])) ++cnt;
else ans = max(ans, cnt), cnt = 0;
}
ans = max(ans, cnt);
outn(ans);
}

C - GeT AC

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

#include <bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define il inline namespace io { #define in(a) a = read()
#define out(a) write(a)
#define outn(a) out(a), putchar('\n') #define I_int ll
inline I_int read() {
I_int x = 0, f = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-') f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
x = x * 10 + c - '0';
c = getchar();
}
return x * f;
}
char F[200];
inline void write(I_int x) {
if (x == 0) return (void) (putchar('0'));
I_int tmp = x > 0 ? x : -x;
if (x < 0) putchar('-');
int cnt = 0;
while (tmp > 0) {
F[cnt++] = tmp % 10 + '0';
tmp /= 10;
}
while (cnt > 0) putchar(F[--cnt]);
}
#undef I_int }
using namespace io; using namespace std; #define N 100010 int n = read(), q = read();
int sum[N];
char s[N]; int main() {
scanf("%s",s+1);
for(int i = 1; i <= n; ++i) {
sum[i] = sum[i - 1];
if(s[i]=='C'&&s[i-1]=='A') {
++sum[i];
}
}
while(q--){
int l = read(), r = read();
outn(sum[r]-sum[l]);
}
}

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的位置是递增的)

map<int,string>mp;
bool check(int a,int b,int c, int d) { if(mp[a]+mp[c]+mp[b]=="AGC") return 0;
if(mp[a]+mp[b]+mp[d]=="AGC") return 0;
if(mp[a]+mp[c]+mp[d]=="AGC") return 0; if(mp[b]+mp[c]+mp[d]=="AGC") return 0;
if(mp[b]+mp[d]+mp[c]=="AGC") return 0; if(mp[c]+mp[b]+mp[d]=="AGC") return 0; return 1;
}

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

#include <bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define il inline namespace io { #define in(a) a = read()
#define out(a) write(a)
#define outn(a) out(a), putchar('\n') #define I_int ll
inline I_int read() {
I_int x = 0, f = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-') f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
x = x * 10 + c - '0';
c = getchar();
}
return x * f;
}
char F[200];
inline void write(I_int x) {
if (x == 0) return (void) (putchar('0'));
I_int tmp = x > 0 ? x : -x;
if (x < 0) putchar('-');
int cnt = 0;
while (tmp > 0) {
F[cnt++] = tmp % 10 + '0';
tmp /= 10;
}
while (cnt > 0) putchar(F[--cnt]);
}
#undef I_int }
using namespace io; using namespace std; #define N 100010
const ll mod = 1e9 + 7;
int n = read();
ll f[N][5][5][5];
/*
f[i][j][a][b]位置i,字符j,i-1字符a,i-2字符b */
map<int,string>mp;
bool check(int a,int b,int c, int d) { if(mp[a]+mp[c]+mp[b]=="AGC") return 0;
if(mp[a]+mp[b]+mp[d]=="AGC") return 0;
if(mp[a]+mp[c]+mp[d]=="AGC") return 0; if(mp[b]+mp[c]+mp[d]=="AGC") return 0;
if(mp[b]+mp[d]+mp[c]=="AGC") return 0; if(mp[c]+mp[b]+mp[d]=="AGC") return 0; return 1;
} int main() {
if(n<=2) return outn(pow(4,n)), 0;
mp[0]='Q'; mp[1]='A'; mp[2]='C';mp[3]='G';mp[4]='T';
f[0][0][0][0]=1;
for(int i = 1; i <= n; ++i)
for(int j = 1; j <= 4; ++j)
for(int a = 0; a <= 4; ++a)
for(int b = 0; b <= 4; ++b)
for(int l = 0; l <= 4; ++l)
if(check(l,b,a,j)) (f[i][j][a][b] += f[i-1][a][b][l]) %= mod;
ll ans = 0;
for(int i = 1; i <= 4; ++i) {
for(int j = 1; j <= 4; ++j) {
for(int k = 1; k <= 4; ++k) {
(ans+=f[n][i][j][k])%=mod;
}
}
}
outn(ans);
}

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. UOJ236 IOI2016 Railroad 差分、欧拉回路、最小生成树

    传送门 将"进入路段时速度\(\leq s_i\)"转换为:"进入路段时速度恰好等于\(s_i\),并且铺设铁轨有加速和减速两种,加速无需代价,减速每\(1 km/h\) ...

  2. Spring Cloud 入门教程(八): 断路器指标数据监控Hystrix Dashboard 和 Turbine

    1. Hystrix Dashboard (断路器:hystrix 仪表盘)  Hystrix一个很重要的功能是,可以通过HystrixCommand收集相关数据指标. Hystrix Dashboa ...

  3. 【JS小技巧】JavaScript 函数用作对象的隐藏问题(F.ui.name)

    用户反馈 @消失的键盘 在论坛反馈了一个问题,在 AppBoxMvc 中的 Title 模型中,如果将 Name 属性改名为小写的 name 属性,就会报错: 因为这是一个 ASP.NET MVC 的 ...

  4. My ajaxwrapper tool

    Until recently, when I write ajax call, always write like below: $.ajax({ type: "post", da ...

  5. 【C#复习总结】探究各类数据结构(Array、List、Queue、Stack)及线程安全问题和yeild关键字

    前言 先普及一下线程安全和类型安全 线程安全: 如果你的代码所在的进程中有多个线程在同时运行,而这些线程可能会同时运行这段代码.如果每次运行结果和单线程运行的结果是一样的,而且其他的变量的值也和预期的 ...

  6. Quartz.NET 任务调度教程。

    https://www.cnblogs.com/yaopengfei/p/9216229.html

  7. 跨语言调用Hangfire定时作业服务

    跨语言调用Hangfire定时作业服务 背景 Hangfire允许您以非常简单但可靠的方式执行后台定时任务的工作.内置对任务的可视化操作.非常方便. 但令人遗憾的是普遍都是业务代码和hagnfire服 ...

  8. xadmin集成DjangoUeditor

    1.安装 安装DjangoUeditor 1)去GitHub上面下载djangoueditor源码包(https://github.com/twz915/DjangoUeditor3)   然后进入源 ...

  9. 二维数组中的查找问题--剑指offer面试题3

    题目:在一个二维数组中,对每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序.请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数. // 二维数组中的查找 ...

  10. NYOJ-16-矩形嵌套 记忆化搜索

    #include<iostream> #include<stdio.h> #include<string.h> #include<algorithm> ...