不想说啥了,比赛期间智商全程下线

A

设$f[i][j]$表示前$i$个位置,前缀和为$j$的方案数,转移的时候该位置放了什么,以及该位置之前的和是多少。

发现第二维可以前缀和优化。

不用管代码里的fib是什么,当时傻了在xjb分析下界。。。。

时间复杂度:$O(nk)$

/*

*/
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/hash_policy.hpp>
#define Pair pair<int, int>
#define MP(x, y) make_pair(x, y)
#define fi first
#define se second
#define int long long
#define LL long long
#define ull unsigned long long
#define rg register
#define pt(x) printf("%d ", x);
//#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1<<22, stdin), p1 == p2) ? EOF : *p1++)
//char buf[(1 << 22)], *p1 = buf, *p2 = buf;
//char obuf[1<<24], *O = obuf;
//void print(int x) {if(x > 9) print(x / 10); *O++ = x % 10 + '0';}
//#define OS *O++ = ' ';
using namespace std;
//using namespace __gnu_pbds;
const int MAXN = 1e6 + , INF = 1e9 + , mod = ;
const double eps = 1e-;
inline int read() {
char c = getchar(); int x = , f = ;
while(c < '' || c > '') {if(c == '-') f = -; c = getchar();}
while(c >= '' && c <= '') x = x * + c - '', c = getchar();
return x * f;
}
int f[][MAXN], s[MAXN], fib[MAXN];
main() {
int N = read(), K = read();//k个位置 总和为n
fib[] = ; fib[] = ;
for(int i = ; i <= N; i++) fib[i] = fib[i - ] + fib[i - ];
for(int i = ; i <= N; i++) f[][i] = , s[i] = (s[i - ] + f[][i]) % mod;
for(int i = ; i <= K; i++) {
for(int j = ; j <= N; j++) {
// for(int k = fib[i - 1]; k <= j / 2; k++) (f[i][j] += f[i - 1][k]) %= mod;
f[i][j] = s[j / ] % mod;
if((j / >= fib[i - ]) && (fib[i - ] >= )) f[i][j] = (f[i][j] - s[fib[i - ] - ] + mod) % mod;
}
s[] = ;
for(int j = ; j <= N; j++)
s[j] = (s[j - ] + f[i][j]) % mod;
} printf("%d", f[K][N] % mod);
return ;
}
/*
15 3
*/

A

B

起点和终点都是已知的,那么对于其他的节点,一定是从根节点走到该节点再往回走。

这样我们记录下根节点到其他节点路径的并,在这之中唯一不需要经过两次的是该节点到根的路径,减去即可

由于每个点只会经过一次,因此时间复杂度为:$O(n+m)$

#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + ;
inline int read() {
char c = getchar(); int x = , f = ;
while(c < '' || c > '') {if(c == '-') f = -; c = getchar();}
while(c >= '' && c <= '') x = x * + c - '', c = getchar();
return x * f;
}
int N, M, dep[MAXN], fa[MAXN], vis[MAXN];
vector<int> v[MAXN];
void dfs(int x, int _fa) {
dep[x] = dep[_fa] + ;
fa[x] = _fa;
for(int i = ; i < v[x].size(); i++) {
int to = v[x][i];
if(to == _fa) continue;
dfs(to, x);
}
}
int main() {
N = read(); M = read();
for(int i = ; i <= N - ; i++) {
int x = read(), y = read();
v[x].push_back(y); v[y].push_back(x);
}
dep[] = -; dfs(, );
vis[] = ;
int tot = , ans = ;
for(int i = ; i <= M; i++) {
int x = read(), tmp = x;
while(!vis[x]) tot++, vis[x] = , x = fa[x];
printf("%d\n", * tot - dep[tmp]);
}
return ;
}
/*
*/

B

C

神仙题Orz

题目里有个很良心的部分分

这就提示我们跟二进制拆分有点关系了

序列上的问题好像很难搞,我们扔到环上去(这是怎么想到的啊Orz)

构造一个这样的环

上下两个$0$不管进化几次肯定都是$0$(左右对称)

考虑其他位置,观察每一项展开后的式子不难发现(发现不了。。)

对于位置$i$,如果$a[i]$进化了$2^d$后变为$c[i]$,那么$c[i] = a[i - 2^d] + a[i+2^d]$

做完了。。

#include<cstdio>
#include<cstring>
#define int long long
using namespace std;
const int MAXN = 1e6 + ;
inline int read() {
char c = getchar(); int x = , f = ;
while(c < '' || c > '') {if(c == '-') f = -; c = getchar();}
while(c >= '' && c <= '') x = x * + c - '', c = getchar();
return x * f;
}
int T, N;
char s[MAXN];
int a[MAXN], b[MAXN];
main() {
T = read(); N = read();
// for(int i = 1; i <= N; i++) a[i] = read();
scanf("%s", s + );
for(int i = ; i <= N; i++) a[i] = s[i] - '', a[N * + - i] = a[i];
N = N * + ;
for(int j = ; j >= ; j--) {
if(T & (1ll << j)) {
int base = (1ll << j) % N;
for(int i = ; i <= N; i++) b[i] = a[(i - base + N) % N] ^ a[(i + base) % N];
memcpy(a, b, sizeof(a));
}
}
for(int i = ; i <= N / - ; i++) printf("%d", a[i]);
return ;
}
/*
2 5
10010
*/

C

ZR18提高5解题报告的更多相关文章

  1. NOIP2016提高组解题报告

    NOIP2016提高组解题报告 更正:NOIP day1 T2天天爱跑步 解题思路见代码. NOIP2016代码整合

  2. 【NOIP2015】提高day2解题报告

    题目: P1981跳石头 描述 一年一度的“跳石头”比赛又要开始了!这项比赛将在一条笔直的河道中进行,河道中分布着一些巨大岩石.组委会已经选择好了两块岩石作为比赛起点和终点.在起点和终点之间,有 N ...

  3. 2010noip提高组解题报告

    https://www.luogu.org/problem/show?pid=1514 题目描述 在一个遥远的国度,一侧是风景秀美的湖泊,另一侧则是漫无边际的沙漠.该国的行政区划十分特殊,刚好构成一个 ...

  4. noip2015 提高组 解题报告

    完美退役...说好的不卡常呢QAQ day1: T1:模拟题?..考察选手将题目描述翻译成代码的能力233 //其实真相是考验rp..论代码雷同的危害233 T2:简单图论,每个点出度为1所以是基环内 ...

  5. Noip2015提高组解题报告

    Day1 T1神奇的幻方 一道简单异常的小模拟,我们只需要确定数字1的位置,然后根据题意枚举即可,简简单单就A了,什么也不卡. 然而这题,我刚开始学OI的时候,因为当时比较蠢,被这题花式吊打啊.... ...

  6. noip2009提高组解题报告

    NOIP2009潜伏者 题目描述 R 国和S 国正陷入战火之中,双方都互派间谍,潜入对方内部,伺机行动. 历尽艰险后,潜伏于 S 国的R 国间谍小C 终于摸清了S 国军用密码的编码规则: 1. S 国 ...

  7. 【NOIP2015】提高组D1 解题报告

    P1978神奇的幻方 Accepted 描述 幻方是一种很神奇的 N ∗ N 矩阵:它由数字 1,2,3, … … , N ∗ N 构成,且每行.每列及两条对角线上的数字之和都相同. 当 N 为奇数时 ...

  8. 【未完成0.0】Noip2012提高组day2 解题报告

    第一次写一套题的解题报告,感觉会比较长.(更新中Loading....):) 题目: 第一题:同余方程 描述 求关于x的同余方程ax ≡ 1 (mod b)的最小正整数解. 格式 输入格式 输入只有一 ...

  9. NOIP2015 提高组(senior) 解题报告

    过了这么久才来发解题报告,蒟蒻实在惭愧 /w\ Day1 T1 [思路] 模拟 [代码] #include<iostream> #include<cstring> #inclu ...

随机推荐

  1. shutdown-用于关闭/重启计算机

    Linux系统下的shutdown命令用于安全的关闭/重启计算机,它不仅可以方便的实现定时关机,还可以由用户决定关机时的相关参数.在执行shutdown命令时,系统会给每个终端(用户)发送一条屏显,提 ...

  2. 第七篇 elasticsearch 链接mysql不会更新

    这是我键的索引 "settings":{ "number_of_shards":3, "number_of_replicas":2 }, & ...

  3. [原创]Devexpress XtraReports 系列索引

    该系列已经完结...以后如果有高级功能,会再开一个新的系列,该系列是比较基础的报表应用..谢谢大家一直的支持. [原创]Devexpress XtraReports 系列 1 创建静态报表 Demo地 ...

  4. (转自精通Python设计模式)Python设计模式之创建型模式——2.建造者模式

    建造者模式将一个复杂对象的构造过程与其表现分离,这样,同一个构造过程可用于创建多个不同的表现. 我们来看个实际的例子,假设我们想要创建一个HMTL页面生成器,HTML页面的基本结构(构造组件)通常是一 ...

  5. p1098 逆序对

    传送门 题目 输入格式: 第一行,一个数n,表示序列中有n个数. 第二行n个数,表示给定的序列. 输出格式: 给定序列中逆序对的数目. 数据范围: 对于50%的数据,n≤2500 对于100%的数据, ...

  6. CodeForces 492D Vanya and Computer Game (思维题)

    D. Vanya and Computer Game time limit per test 2 seconds memory limit per test 256 megabytes input s ...

  7. CSS学习系列1 - CSS中的盒子模型 box model

    css中有一个盒子模型的概念. 主要是用来告诉浏览器如何来计算页面元素的宽度和高度, 比如该元素的宽度/高度 是否包括内边距,边框,外边距.  盒子模型有一个属性box-sizing属性来说明是否包括 ...

  8. Go语言学习记录之一(返回指针与返回值的区别)

    先来一个返回指针的测试,结果跟想象一样 type A map[int]string type B struct { A c int } func main() { b := B{make(A), 10 ...

  9. MySQL数据库修改字符集为UTF-8

    需要修改my.ini [client]下添加 default_character_set = utf8 [mysql]下添加 default_character_set = utf8 [mysqld] ...

  10. C# Collection was modified;enumeration operation may not execute

    一.问题描述 在做 数组.列表.集合遍历时,可能我们会遇见这个问题.Collection was modified;enumeration operation may not execute ,翻译的 ...