http://codeforces.com/contest/877/problem/E 真的菜的不行,自己敲一个模板,到处都是问题.哎 #include <bits/stdc++.h> using namespace std; ; #define lson (q<<1) #define rson ((q<<1)|1) struct node { int l,r,mid; int v,lazy; }tree[maxn*]; int L[maxn],R[maxn],inde…
题意: 给出一个具有N个点的树,现在给出两种操作: 1.get x,表示询问以x作为根的子树中,1的个数. 2.pow x,表示将以x作为根的子树全部翻转(0变1,1变0). 思路:dfs序加上一个线段树区间修改查询. AC代码: #include<iostream>#include<vector>#include<string.h>using namespace std;const int maxn=2e5+5;int sum[maxn<<2],lazy[…
A. Alex and broken contest 题意 判断一个字符串内出现五个给定的子串多少次. Code #include <bits/stdc++.h> char s[110]; using namespace std; typedef long long LL; char* rec[5] = {"Danil", "Olya", "Slava", "Ann", "Nikita"}; i…
A. Alex and broken contest time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output One day Alex was creating a contest about his friends, but accidentally deleted it. Fortunately, all the problems…
A. Alex and broken contest time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output One day Alex was creating a contest about his friends, but accidentally deleted it. Fortunately, all the problems…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 注意是所有的名字里面,只出现了其中某一个名字一次. [代码] #include <bits/stdc++.h> using namespace std; const string temp[] = {"Danil","Olya","Slava","Ann","Nikita"}; string s; int num[5]; int…
[链接] 我是链接,点我呀:) [题意] 给一张二维点格图,其中有一些点可以走,一些不可以走,你每次可以走1..k步,问你起点到终点的最短路. [题解] 不能之前访问过那个点就不访问了.->即k那一层循环直接break; 因为可能出现这种 ax aa aa 然后起点是(3,2)终点是(1,1);然后k=3 bfs的时候,第一步,走到了(2,2)和(3,1); 但是接下来,如果(2,2)先走的话,就会先走到(2,1); 而(3,1)认为(2,2)走过了,就不往下走了. ->但实际上他可以一步走到…
[链接] 我是链接,点我呀:) [题意] 有n个位置,每个位置都可能有不定数量的tank; 你每次可以选择一个位置投掷炸弹. 并且,这个位置上的所有tank都会受到你的攻击. 并且失去一点体力. 然后它们可能会往左走一格,或者往右走一格. 每个tank的体力都为2. 问你打掉所有的tank最坏情况要多少次轰炸操作.然后输出所有的轰炸位置. [题解] 在2,4,6...轰炸 然后在1,3,5...轰炸 最后在2,4,6轰炸. 可以保证每个tank都被炸死. [代码] #include <bits/…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 枚举中间那一段从哪里开始.哪里结束就好 注意为空的话,就全是a. 用前缀和优化一下. [代码] #include <bits/stdc++.h> using namespace std; const int N = 5e3; string s; int a[N+10],pre[N+10][2],ans; int main(){ //freopen("rush.txt","r",stdin…
B. Nikita and string One day Nikita found the string containing letters "a" and "b" only. Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st…