ZR18提高5解题报告
不想说啥了,比赛期间智商全程下线
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解题报告的更多相关文章
- NOIP2016提高组解题报告
NOIP2016提高组解题报告 更正:NOIP day1 T2天天爱跑步 解题思路见代码. NOIP2016代码整合
- 【NOIP2015】提高day2解题报告
题目: P1981跳石头 描述 一年一度的“跳石头”比赛又要开始了!这项比赛将在一条笔直的河道中进行,河道中分布着一些巨大岩石.组委会已经选择好了两块岩石作为比赛起点和终点.在起点和终点之间,有 N ...
- 2010noip提高组解题报告
https://www.luogu.org/problem/show?pid=1514 题目描述 在一个遥远的国度,一侧是风景秀美的湖泊,另一侧则是漫无边际的沙漠.该国的行政区划十分特殊,刚好构成一个 ...
- noip2015 提高组 解题报告
完美退役...说好的不卡常呢QAQ day1: T1:模拟题?..考察选手将题目描述翻译成代码的能力233 //其实真相是考验rp..论代码雷同的危害233 T2:简单图论,每个点出度为1所以是基环内 ...
- Noip2015提高组解题报告
Day1 T1神奇的幻方 一道简单异常的小模拟,我们只需要确定数字1的位置,然后根据题意枚举即可,简简单单就A了,什么也不卡. 然而这题,我刚开始学OI的时候,因为当时比较蠢,被这题花式吊打啊.... ...
- noip2009提高组解题报告
NOIP2009潜伏者 题目描述 R 国和S 国正陷入战火之中,双方都互派间谍,潜入对方内部,伺机行动. 历尽艰险后,潜伏于 S 国的R 国间谍小C 终于摸清了S 国军用密码的编码规则: 1. S 国 ...
- 【NOIP2015】提高组D1 解题报告
P1978神奇的幻方 Accepted 描述 幻方是一种很神奇的 N ∗ N 矩阵:它由数字 1,2,3, … … , N ∗ N 构成,且每行.每列及两条对角线上的数字之和都相同. 当 N 为奇数时 ...
- 【未完成0.0】Noip2012提高组day2 解题报告
第一次写一套题的解题报告,感觉会比较长.(更新中Loading....):) 题目: 第一题:同余方程 描述 求关于x的同余方程ax ≡ 1 (mod b)的最小正整数解. 格式 输入格式 输入只有一 ...
- NOIP2015 提高组(senior) 解题报告
过了这么久才来发解题报告,蒟蒻实在惭愧 /w\ Day1 T1 [思路] 模拟 [代码] #include<iostream> #include<cstring> #inclu ...
随机推荐
- shell脚本备份系统的方法
linux自动备份shell(使用全备份,增量备份策略) 在cron里设置,每周日晚12点执行(每周日全备份,其余时间增量备份)#vi backup.sh #!/bin/bash # definewe ...
- linux docket
什么是 Docker Docker 最初是 dotCloud 公司创始人 Solomon Hykes 在法国期间发起的一个公司内部项目,它是基于 dotCloud 公司多年云服务技术的一次革新,并于 ...
- 25. CTF综合靶机渗透(17)
靶机链接 https://www.vulnhub.com/entry/the-ether-evilscience,212 运行环境 本靶机提供了VMware的镜像,从Vulnhub下载之后解压,运行v ...
- angular使用base64的encode和decode
var app = angular.module("encodeDecode", []); app.controller("encodeDecodeCtrl", ...
- BOX (UVA-1587) 比较代码书写上的差距
对比一下代码的书写差距: 我的代码: #include<iostream> using namespace std; ]; ]; ]; //访问标记 bool judge(int i, i ...
- uWSGI + Nginx + Django 部署
1. uWSGI 服务器 Django 默认使用 WSGI(Python Web Server Gateway ) 作为 Web 服务器,一般仅用来作为测试使用,实际生产环境而是使用 uWSGI 和 ...
- iis应用程序池没有fromwork 4.0-----安装iis
找到已经安装的目录 C:\Windows\Microsoft.NET\Framework\v4.0.30319 以管理员身份运行一下就ok 安装iis 控制面板-程序与功能-打开与关闭window ...
- 2、Jquery_事件
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...
- 消息队列--RabbitMQ(二)
1.常用的几种队列简介 RabbitMQ有五种常用的队列,分别是:简单队列.work模式.发布订阅模式.路由模式.主题(Topic)模式.其实发布订阅.路由.主题这三种模式都从属于与routingke ...
- ASP.NET MVC 小牛之旅2:体验第一个MVC程序
了解了什么是MVC之后,接下来用一个非常简单的留言板程序概要的了解MVC网站开发的过程,对MVC开发有个大致的轮廓.第一个项目将不会提到过多与数据库相关的技术,因此将以Framework Code F ...