Kickstart Round H 2018
打了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的更多相关文章
- Let Me Count The Ways(Kickstart Round H 2018)
题目链接:https://code.google.com/codejam/contest/3324486/dashboard#s=p2 题目: 思路: 代码实现如下: #include <set ...
- Kickstart Round H 2019 Problem B. Diagonal Puzzle
有史以来打得最差的一次kickstart竟然发生在winter camp出结果前的最后一次ks = = 感觉自己的winter camp要凉了 究其原因,无非自己太眼高手低,好好做B, C的小数据,也 ...
- Kickstart Round G 2018
第一次打codejam....惨的一比,才A1.5题,感觉自己最近状态渣到姥姥家了,赶紧练练 A 模拟,注意0的问题 #include <iostream> #include <cs ...
- Google Kickstart Round E 2018 B. Milk Tea
太蠢了,,,因为初始化大数据没过,丢了10分,纪念一下这个错误 大概思路:先求出让损失值最小的排列,由已生成的这些排列,通过更改某一个位置的值,生成下一个最优解,迭代最多生成m+1个最优解即可,遍历求 ...
- 2019 google kickstart round A
第一题: n个人,每个人有一个对应的技能值s,现在要从n个人中选出p个人,使得他们的技能值相同. 显然,如果存在p个人的技能值是相同的,输出0就可以了.如果不存在,就要找出p个人,对他们进行训练,治他 ...
- google Kickstart Round F 2017 四道题题解
Problem A. Kicksort 题意抽象一下为: 对于一个每次都从数列正中间取划分数的快速排序,给定一个1-n的排列,问快排的复杂度对于这个排列是否会退化为最坏复杂度. 数据范围: 测试组数1 ...
- 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 ...
- 【贪心】Google Code Jam Round 1A 2018 Waffle Choppers
题意:给你一个矩阵,有些点是黑的,让你横切h刀,纵切v刀,问你是否能让切出的所有子矩阵的黑点数量相等. 设黑点总数为sum,sum必须能整除(h+1),进而sum/(h+1)必须能整除(v+1). 先 ...
- Kickstart Round D 2017 problem A sightseeing 一道DP
这是现场完整做出来的唯一一道题Orz..而且还调了很久的bug.还是太弱了. Problem When you travel, you like to spend time sightseeing i ...
随机推荐
- 在windows下的hdfs客户端编写
在windows下的hdfs客户端编写 新建一个工程,右键 properties -> java build path -> libraries 和之前一样的操作,这次 new 一个 us ...
- ajax本地跨域请求以及解决方法
什么是跨域? 我们通常所说的跨域是狭义的,是由浏览器同源策略限制的一类请求场景.所谓同源是指"协议+域名+端口"三者相同,即便两个不同的域名指向同一个ip地址,也非同源,只要没 ...
- Spring 入门(概述)
1.什么是框架 2.Spring简介 3.IOC(配置.注解) 4.Bean(配置.注解) 5.AOP(配置.注解.AspectJ.API) 资源: http://spring.io/ http:// ...
- 【原创】python requests 库底层Sockets处于close_wait状态
以前对于Requests库只是简单是使用,在现在公司的后台中,有多个接口是直接使用requests.get .post之类的方法来做的,进行过一段时间的压力测试,发现性能低的可怜,且linux服务器有 ...
- 【CF1009F】Dominant Indices
题目 长链剖分板子题啊 长链剖分有几个神奇的性质 所有长链的总点数为\(n\) 任意一个点的\(k\)级祖先所在长链的长度肯定不小于\(k\) 从任意点到根经过的短边数量不超过\(\sqrt{n}\) ...
- httpd:RSA certificate configured for SERVER does NOT include an ID which matches the server name
这个是因为ssl认证丢失了密钥的问题,Apache的默认配置文件加载了mod_ssl模块,而且指定密钥对儿的位置,就是我测试salt-api时创建密钥对儿的位置.而且还有一个错误就是我密钥对儿指定的h ...
- 多线程之Timer和TimerTask
Timer是一种线程设施,用于安排以后在后台线程中执行的任务.可安排任务执行一次,或者定期重复执行,可以看成一个定时器,可以调度TimerTask.TimerTask是一个抽象类,实现了Runnabl ...
- C++:引用的简单理解
前言:引用是C++一个很重要的特性,最近看了很多有关引用的资料和博客,故在此对引用的相关知识进行总结 一.什么是引用 引用,顾名思义是某一个变量或对象的别名,对引用的操作与对其所绑定的变量或对象的操作 ...
- 名字&值
1)名字VS值 名字和内存(存储)位置相关联. 名字—(环境)———>位置——(状态)——>值 这两个映射都在随着程序的运行而改变. 2)环境VS状态 环境是指一个名字到存储位置映射,也可 ...
- Linux服务-ftp
目录 1. ftp简介 2. ftp架构 3. ftp数据连接模式 4. 用户认证 5. vsftpd 5.1 vsftpd安装 5.2 vsftpd配置 5.3 vsftpd实验配置 5.3.1 安 ...