地址:http://codeforces.com/contest/768/problem/C 题目: C. Jon Snow and his Favourite Number time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Jon Snow now has to fight with White Walkers. He has…
地址:http://codeforces.com/contest/768/problem/D 题目: D. Jon and Orbs time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Jon Snow is on the lookout for some orbs required to defeat the white wal…
地址:http://codeforces.com/problemset/problem/768/A 题目: A. Oath of the Night's Watch time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output "Night gathers, and now my watch begins. It shall not end…
地址:http://codeforces.com/contest/768/problem/B 题目: B. Code For 1 time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Jon fought bravely to rescue the wildlings who were attacked by the white-w…
C题卡了好久,A掉C题之后看到自己已经排在好后面说实话有点绝望,最后又过了两题,总算稳住了. AC:ABCDE Rank:191 Rating:2156+37->2193 A.Oath of the Night's Watch 题目大意:给定N个数,求有多少个数存在严格比它大的数和严格比它小的数.(N<=100,000) 思路:阅读能力训练+手速,排序一遍就没了. #include<cstdio> #include<cstring> #include<algori…
A. Oath of the Night's Watch time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output "Night gathers, and now my watch begins. It shall not end until my death. I shall take no wife, hold no lands,…
打表找规律即可. 1,1,2,2,2,3,3,3,3,4,4,4,4,4... 注意打表的时候,sg值不只与剩下的石子数有关,也和之前取走的方案有关. //#include<cstdio> //#include<set> //#include<cstring> //using namespace std; //bool vis[16]; //int n,SG[16][1<<16]; //int sg(int x,int moved) //{ // if(SG…
直接暴力dp就行……f(i,j)表示前i天集齐j种类的可能性.不超过10000天就能满足要求. #include<cstdio> using namespace std; #define EPS 1e-10 int K,q,p; double f[10010][1010]; int main() { // freopen("d.in","r",stdin); scanf("%d%d",&K,&q); f[0][0]=1…
发现值域很小,而且怎么异或都不会超过1023……然后可以使用类似基数排序的思想,每次扫一遍就行了. 复杂度O(k*1024). #include<cstdio> #include<cstring> using namespace std; int n,k,x,cnts[1110],tmpcnts[1110]; int main() { // freopen("c.in","r",stdin); int X; scanf("%d%d%…
观察一下,将整个过程写出来,会发现形成一棵满二叉树,每一层要么全是0,要么全是1. 输出的顺序是其中序遍历. 每一层的序号形成等差数列,就计算一下就可以出来每一层覆盖到的区间的左右端点. 复杂度O(log(n)). #include<cstdio> using namespace std; typedef long long ll; ll n,l,r; bool a[66]; int e; int main() { // freopen("b.in","r&quo…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 把序列生成的过程看成一颗树 会发现最后形成的是一颗二叉树. 每个二叉树上的节点就对应了序列中的一个数字. 如果我们把每个节点都往下投影的话. (而且整棵树都是左右对称的.那么每个子树的根节点就是(l+r)/2了 就像是整个序列了. (中序遍历 则我们可以用线段树求区间和的方法. 现在相当于告诉你1..n这个区间. 然后你要求l..r这个区间的和. 递归求就好. [代码] #include <bits/stdc++.h> #de…
[题目链接]:http://codeforces.com/contest/768/problem/C [题意] 给你n个数字; 让你每次把这n个数字排序; 然后对奇数位的数字进行异或操作,然后对新生成的序列再重复上述操作总共k次; 问最后的序列的最小值和最大值分别是多少; [题解] 可以用计数排序来搞; 因为数字最大为1000; 所以将近O(K*1000)的复杂度; 完全可以的; 每次从小到大(0到1000(枚举数字; 然后根据该数字的个数判断该数字有几个数字要进行异或,几个数字保持原样. 然后…
题目链接:http://codeforces.com/contest/768/problem/C 题意:给出n个数,k个操作,和一个x,每次操作先排序然后对奇数位数进行xor x操作,最后问k次操作后最大值和最小值 为多少. 题解:看似是要找规律的但是只要暴力就行了.主要是a[i]的范围就只有10的3次,而且时间还有4s,直接来一个vis[i]表示 0-2048个数内取了几个,这样排序都不用了.直接for 0-2048就行.(2的10次1024,异或2的9次就是,2的11次减1 所以设最大为20…
题意: 给出一个数列,和一种操作,以及两个数x和k. 这个操作有两个步骤: 首先把这个数列按照升序排序,然后把所有奇数位上的数字与x异或. 问执行k次操作之后,这个数列的最大值和最小值是多少. 思路: 由于每个数字异或两次之后会变回本身,所以猜测这个数列有可能会循环,所以就可以暴力计算周期,对于每一次出现的数列,看看是否与前面某次出现过的数列相同,这是暴力的思路.玄学复杂度. 更优雅的思路: 发现a[i]的最大值为1000,任意1000以内的两个数字异或不会超过1023,所以可以统计0到1023…
https://vjudge.net/problem/CodeForces-768C 题意:n个数,k次操作,x.每次操作先排序,再让奇数位置上的数据a[i]:=a[i] XOR x;   k<1e5,x<1e5,a[i]<1e3. 题解:由于每个数据为1~1000,且每次操作先排序,所以可以用桶排序维护所有数据.然后模拟操作(我自己模拟的一直wa,换了另一种才ac). 网上另外也有人k%=64 然后暴力ac了,还有找循环节的也ac 了. 坑:第一次看codeforce 的数据,结果ou…
链接 题意 给定数组, 每次操作先将数组排序, 再将奇数位全部异或x, 求k次操作后数组最大值与最小值 (1 ≤ n ≤ 105, 0 ≤ k ≤ 105, 0 ≤ x ≤ 103) 题解 直接暴力模拟是O(nk)的, 注意到元素范围均较小可以用桶达到O(1024*k) 该题k过大时会好像一定出现循环, 然后暴力模拟几次也能过, 没看出来怎么证明... #include <iostream>#include <cstdio> #include <algorithm> #…
Problem   Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec Problem Description Input Output The only line should contain the minimal number of days required for the ship to reach the point (x2,y2)(x2,y2). If it…
Problem   Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec Problem Description Input The input contains a single line consisting of 2 integers N and M (1≤N≤10^18, 2≤M≤100). Output Print one integer, the total n…
Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include<bits/stdc++.h> using namespace std; #define lson l,mid,rt<<1 #define rson mid+1,r,rt<<1|1 #define IT set<ll>::iterator #define sqr(x)…
Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 A 模拟 #include<bits/stdc++.h> using namespace std; #define lson l,mid,rt<<1 #define rson mid+1,r,rt<<1|1 #define IT set<ll>::iterator #define sqr(…
Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings 题目连接: http://codeforces.com/contest/985/problem/F Description You are given a string s of length n consisting of lowercase English letters. For two given strings s an…
Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes 题目连接: http://codeforces.com/contest/985/problem/E Description Mishka received a gift of multicolored pencils for his birthday! Unfortunately he lives in a monochrome w…
Educational Codeforces Round 63 (Rated for Div. 2)题解 题目链接 A. Reverse a Substring 给出一个字符串,现在可以对这个字符串进行一次翻转,问是否存在一种方案,可以使得翻转后字符串的字典序可以变小.   这个很简单,贪心下就行了. 代码如下: Code #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 3e5…
Educational Codeforces Round 39 (Rated for Div. 2) G 题意: 给一个序列\(a_i(1 <= a_i <= 10^{9}),2 <= n <= 200000\), 如果至多删除其中的一个数之后该序列为严格上升序列,那么称原序列为几乎严格上升序列. 现在每次将序列中的任意数字变成任意数字,问最少要操作几次才能将序列变成几乎严格上升子序列. 思路: 如果不考虑删除,求让整个序列都变成严格上升子序列的次数 求出\(序列a_i - i\)…
Educational Codeforces Round 48 (Rated for Div. 2) C. Vasya And The Mushrooms 题目链接:https://codeforces.com/contest/1016/problem/C 题意: emmm,说不清楚,还是直接看题目吧. 题解: 这个题人行走的方式是有一定的规律的,最后都是直接走到底,然后从另外一行走回来.并且通过画图观察,会发现他走到格子的时间会有一定的规律. 所以就维护几个前缀和就行了,从1到n枚举一下,还要…
Educational Codeforces Round 60 (Rated for Div. 2) 题目链接:https://codeforces.com/contest/1117 A. Best Subsegment 题意: 给出n个数,选取一段区间[l,r],满足(al+...+ar)/(r-l+1)最大,这里l<=r,并且满足区间长度尽可能大. 题解: 因为l可以等于r,所以我们可以直接考虑最大值,因为题目要求,直接求连续的最大值的长度就是了. 代码如下: #include <bits…
Educational Codeforces Round 59 (Rated for Div. 2) D. Compression 题目链接:https://codeforces.com/contest/1107/problem/D 题意: 给出一个n*(n/4)的矩阵,这个矩阵原本是一些01矩阵,但是现在四个四个储存进二进制里面,现在给出的矩阵为0~9以及A~F,表示0~15. 然后问这个矩阵能否压缩为一个(n/x)*(n/x)的矩阵,满足原矩阵中大小为x*x的子矩阵所有数都相等(所有子矩阵构…
Educational Codeforces Round 58 (Rated for Div. 2)  题目总链接:https://codeforces.com/contest/1101 A. Minimum Integer 题意: 多组数据,给你三个数l,r,d,要求在区间[l,r]之外找一个最小的x,使得x%d==0. 题解: 当d<l or d>r的时候,直接输出d就好了. 当l<=d<=r的时候,找到最小的t,使得t*d>r就行了. 具体操作见代码: #include…
Educational Codeforces Round 34 (Rated for Div. 2) A Hungry Student Problem 题目链接: http://codeforces.com/contest/903/problem/A 思路: 直接模拟 代码: #include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d",&n); while(n--) { i…
Educational Codeforces Round 69 (Rated for Div. 2) E. Culture Code 题目链接 题意: 给出\(n\)个俄罗斯套娃,每个套娃都有一个\(in_i,out_i\),并满足\(out_i>in_i\).定义套娃\(i\)能套在套娃\(j\)里面,当且仅当\(out_i\leq in_j\). 定义极大套娃组:当且仅当不能有另外一个套娃套在它们身上. 定义套娃组额外空间为\(in_1+(in_2-out_1)+\cdots +(in_k-…