打了ks好久都没有更新

诶,自己的粗心真的是没救了,A题大数据都能错

A

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <algorithm>
#include <functional>
#include <assert.h>
#include <iomanip>
using namespace std;
// const int N = 7005;
// const int M = 2e5 + 5;
const int INF = 0x3f3f3f3f;
const int MOD = 1000000007;
typedef long long ll; char seq[105][55];
int tot, Root;
int nx[10005][2];
int tag[10005];
int newNode() {
nx[tot][0] = nx[tot][1] = -1; tag[tot] = 0;
return tot ++;
}
int N, P; void Insert(char* s) {
int len = strlen(s);
int root = Root;
for(int i = 0; i < len; ++i) {
int id = s[i] == 'R';
if(nx[root][id] == -1) {
nx[root][id] = newNode();
}
root = nx[root][id];
}
tag[root] ++;
} ll dfs(int rt, int deep) {
if(tag[rt]) return 1ll<<(N - deep);
ll ans = 0;
if(nx[rt][0] != -1) ans += dfs(nx[rt][0], deep + 1);
if(nx[rt][1] != -1) ans += dfs(nx[rt][1], deep + 1);
return ans;
}
int main() {
freopen("A-large-practice2.in", "r", stdin);
freopen("A-large-practice2.out", "w", stdout);
int T;
scanf("%d", &T);
for(int _ = 1; _ <= T; ++_) {
tot = 0;
Root = newNode();
scanf("%d %d", &N, &P);
for(int i = 0; i < P; ++i) {
scanf("%s", seq[i]);
Insert(seq[i]);
}
printf("Case #%d: %lld\n", _, (1ll<<N) - dfs(Root, 0)); }
return 0;
}

B

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <algorithm>
#include <functional>
#include <assert.h>
#include <iomanip>
using namespace std;
const int M = 5e6 + 5;
const int INF = 0x3f3f3f3f;
const int MOD = 1000000007;
typedef long long ll; char seq[M];
int main() {
freopen("B-large.in", "r", stdin);
freopen("B-large.out", "w", stdout);
int T;
scanf("%d", &T);
for(int _ = 1; _ <= T; ++_) {
int n;
scanf("%d %s", &n, seq + 1);
int ans = 0; int tmp = 0;
for(int i = 1; i <= (n+1)/2; ++i) {
tmp += seq[i] - '0';
}
ans = max(ans, tmp);
for(int i = (n+1)/2 + 1, j = 1; i <= n; ++i, ++j) {
tmp -= seq[j] - '0';
tmp += seq[i] - '0';
ans = max(ans, tmp);
} printf("Case #%d: %d\n", _, ans); }
return 0;
}

C容斥原理

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <algorithm>
#include <functional>
#include <assert.h>
#include <iomanip>
using namespace std;
// const int N = 7005;
const int M = 2e5 + 5;
const int INF = 0x3f3f3f3f;
const int MOD = 1000000007;
typedef long long ll; ll Mul[M];
ll Pow(ll x, ll y) {
ll ans = 1;
while(y) {
if(y & 1) ans = 1ll * ans * x % MOD;
x = 1ll * x * x % MOD;
y >>= 1;
}
return ans;
} ll C(int x, int y) {
if(y == 0) return 1;
if(x == y) return 1;
return 1ll* Mul[x] * Pow(Mul[y] * Mul[x - y] % MOD, MOD - 2) % MOD;
}
int main() {
freopen("C-small-attempt0.in", "r", stdin);
freopen("C-small-attempt0.out2", "w", stdout);
int T;
scanf("%d", &T);
Mul[1] = 1;
Mul[0] = 1;
for(int i = 2; i < M; ++i) {
Mul[i] = Mul[i-1] * i % MOD;
}
for(int _ = 1; _ <= T; ++_) {
int n, m;
scanf("%d %d", &n, &m);
ll ans = Mul[2*n];
int init = 2*n; ll mul2 = 1;
for(int i = 1; i <= m; ++i) {
init --;
mul2 = mul2 * 2 % MOD;
ll tmp = mul2 * Mul[init] % MOD * C(m, i) % MOD;
ans = (ans + ( (i % 2) ? -tmp : tmp) + MOD) % MOD;
} printf("Case #%d: %lld\n", _, ans);
}
return 0;
}

Kickstart Round H 2018的更多相关文章

  1. Let Me Count The Ways(Kickstart Round H 2018)

    题目链接:https://code.google.com/codejam/contest/3324486/dashboard#s=p2 题目: 思路: 代码实现如下: #include <set ...

  2. Kickstart Round H 2019 Problem B. Diagonal Puzzle

    有史以来打得最差的一次kickstart竟然发生在winter camp出结果前的最后一次ks = = 感觉自己的winter camp要凉了 究其原因,无非自己太眼高手低,好好做B, C的小数据,也 ...

  3. Kickstart Round G 2018

    第一次打codejam....惨的一比,才A1.5题,感觉自己最近状态渣到姥姥家了,赶紧练练 A 模拟,注意0的问题 #include <iostream> #include <cs ...

  4. Google Kickstart Round E 2018 B. Milk Tea

    太蠢了,,,因为初始化大数据没过,丢了10分,纪念一下这个错误 大概思路:先求出让损失值最小的排列,由已生成的这些排列,通过更改某一个位置的值,生成下一个最优解,迭代最多生成m+1个最优解即可,遍历求 ...

  5. 2019 google kickstart round A

    第一题: n个人,每个人有一个对应的技能值s,现在要从n个人中选出p个人,使得他们的技能值相同. 显然,如果存在p个人的技能值是相同的,输出0就可以了.如果不存在,就要找出p个人,对他们进行训练,治他 ...

  6. google Kickstart Round F 2017 四道题题解

    Problem A. Kicksort 题意抽象一下为: 对于一个每次都从数列正中间取划分数的快速排序,给定一个1-n的排列,问快排的复杂度对于这个排列是否会退化为最坏复杂度. 数据范围: 测试组数1 ...

  7. google Kickstart Round G 2017 三道题题解

    A题:给定A,N,P,计算A的N!次幂对P取模的结果. 数据范围: T次测试,1 ≤ T ≤ 100 1<=A,N,P<=105 快速幂一下就好了.O(nlogn). AC代码: #inc ...

  8. 【贪心】Google Code Jam Round 1A 2018 Waffle Choppers

    题意:给你一个矩阵,有些点是黑的,让你横切h刀,纵切v刀,问你是否能让切出的所有子矩阵的黑点数量相等. 设黑点总数为sum,sum必须能整除(h+1),进而sum/(h+1)必须能整除(v+1). 先 ...

  9. Kickstart Round D 2017 problem A sightseeing 一道DP

    这是现场完整做出来的唯一一道题Orz..而且还调了很久的bug.还是太弱了. Problem When you travel, you like to spend time sightseeing i ...

随机推荐

  1. #001 GIT创建分支

    GitHub创建分支 如何在github 创建 一个分支出来,进行开发,最后在 merge 到主干上. Git 操作命令 git branch branchName //创建一个分支 git chec ...

  2. JQuery $.axaj的基本格式

    总是忘了,保存以备后用. $.ajax({ url: '', //请求的url地址 dataType: "json", //返回的格式为json async: true, //请求 ...

  3. html操作

    HTML(hyper text markup language): 超文本标记语言,标准通用标记语言下的一个应用. 超文本就是指页面内可以包含图片.连接.音乐.程序等非文字元素. 超文本标记语言的结构 ...

  4. 1015. [JSOI2008]星球大战【并查集】

    Description 很久以前,在一个遥远的星系,一个黑暗的帝国靠着它的超级武器统治者整个星系.某一天,凭着一个偶然的 机遇,一支反抗军摧毁了帝国的超级武器,并攻下了星系中几乎所有的星球.这些星球通 ...

  5. Hive学习之路 (十二)Hive SQL练习之影评案例

    案例说明 现有如此三份数据:1.users.dat 数据格式为: 2::M::56::16::70072, 共有6040条数据对应字段为:UserID BigInt, Gender String, A ...

  6. koa2怎么自定义一个中间件

    首先定义一个方法 function test(ctx){ global.console.log('m1') } 把这个中间件导出去 module.exports=function(){ return ...

  7. layui弹出层之应用实例讲解

    从酒店管理系统到智能门锁及其现在的资源共享平台,layui框架,我们团队用的比较多的就是这个layui弹出层. layui弹出层,除了页面iframe层我们比较常用还有就是表单校验和其他相关的友好提示 ...

  8. the django travel(two)分页

    一:django路由系统: 注意:我们在urls.py中 定义url的时候,可以加$和不加$,区别的是:加$正则匹配的时候,比如:'/index/$'只能匹配'/index/'这样的url 不能匹配' ...

  9. http协议cookie结构分析

    Http协议中Cookie详细介绍   Cookie总是保存在客户端中,按在客户端中的存储位置,可分为内存Cookie和硬盘Cookie.内存Cookie由浏览器维护,保存在内存中,浏览器关闭后就消失 ...

  10. 【题解】洛谷P1070 道路游戏(线性DP)

    次元传送门:洛谷P1070 思路 一开始以为要用什么玄学优化 没想到O3就可以过了 我们只需要设f[i]为到时间i时的最多金币 需要倒着推回去 即当前值可以从某个点来 那么状态转移方程为: f[i]= ...