Vitya in the Countryside】的更多相关文章

A. Vitya in the Countryside time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output Every summer Vitya comes to visit his grandmother in the countryside. This summer, he got a huge wart. Every gran…
A. Vitya in the Countryside 题目连接: http://codeforces.com/contest/719/problem/A Description Every summer Vitya comes to visit his grandmother in the countryside. This summer, he got a huge wart. Every grandma knows that one should treat warts when the…
A. Vitya in the Countryside time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Every summer Vitya comes to visit his grandmother in the countryside. This summer, he got a huge wart. Every gran…
Description Every summer Vitya comes to visit his grandmother in the countryside. This summer, he got a huge wart. Every grandma knows that one should treat warts when the moon goes down. Thus, Vitya has to catch the moment when the moon is down. Moo…
Every summer Vitya comes to visit his grandmother in the countryside. This summer, he got a huge wart. Every grandma knows that one should treat warts when the moon goes down. Thus, Vitya has to catch the moment when the moon is down. Moon cycle last…
time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Every summer Vitya comes to visit his grandmother in the countryside. This summer, he got a huge wart. Every grandma knows that one should tr…
题目链接:http://codeforces.com/problemset/problem/719/A 题目大意: 题目给出了一个序列趋势 0 .1 .2 .3 ---14 .15 .14 ----3 . 2 .1 .0.1--- 输入 整数 n ,第二行输入 n(1<=n<=92) 个数,判断下个数 是大于最后一个数还是小于最后一个,大于输出 UP,小于输出 DOWN,如果没法判断 输出 -1. 解题思路: 找转折点即可. 特判 n==1. 剩下的代码解释. AC Code: #includ…
题目大意:月亮从0到15,15下面是0.循环往复.给出n个数字,如果下一个数字大于第n个数字输出UP,小于输出DOWN,无法确定输出-1. 题目思路:给出0则一定是UP,给出15一定是DOWN,给出其他的一个数字(n==1)无法确定,其他的情况比较后两位. #include<iostream> #include<algorithm> #include<cstring> #include<vector> #include<stdio.h> #inc…
链接:[http://codeforces.com/group/1EzrFFyOc0/contest/719/problem/A] 题意: 给你一个数列(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1),然后重复循环这个数列,输入一个n,再输入有n个元素的某段,问你接下来是UP还是DOWN,若无法判断输出-1. 思路: 枚举各种情况,注意n==1…
题意:根据题目,给定一些数字,让你判断是上升还是下降. 析:注意只有0,15时特别注意一下,然后就是14 15 1 0注意一下就可以了. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <iostr…
Codeforces Round #371 (Div. 2) A. Meeting of Old Friends |B. Filya and Homework A. Meeting of Old Friends  模拟 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> using namespace std; typedef long long ll;…
A. Vitya in the Countryside time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Every summer Vitya comes to visit his grandmother in the countryside. This summer, he got a huge wart. Every gran…
Codeforces Round #373 (Div. 2) A. Vitya in the Countryside 这回做的好差啊,a想不到被hack的数据,b又没有想到正确的思维 = = [题目链接]A. Vitya in the Countryside [题目类型]模拟 &题意: 一个月30天,月亮的大小分别是上面所说的规律,求输入的下一天是变大还是变小 &题解: 我想的是首先n==1的时候,我想的是一定-1,但这样是错的,因为当那一个数是15或0时,那么答案就不是-1了. 最后,只…
用了两场比赛上Div 1感觉自己好腊鸡的说...以下是这两场比赛的部分题解(不得不说有个黄学长来抱大腿还是非常爽的) Round #372 : Div 2 A:Crazy Computer 题意:给定N个输入和一个时间长度M,每次输入屏幕上增加一个字符,若两个输入间隔大于M则屏幕上的字符会被清空,问结束时屏幕上还有多少个字符 直接模拟没有什么好说的 代码: #include<cstdio> #include<iostream> #include<cstring> #in…
参考自:https://www.cnblogs.com/ECJTUACM-873284962/p/6395221.html A. Vitya in the Countryside time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output Every summer Vitya comes to visit his grandmother i…
A - Complete the Word(暴力) Description ZS the Coder loves to read the dictionary. He thinks that a word is nice if there exists a substring (contiguous segment of letters) of it of length 26 where each letter of English alphabet appears exactly once.…
每周日更新 2016.05.29 UVa中国麻将(Chinese Mahjong,Uva 11210) UVa新汉诺塔问题(A Different Task,Uva 10795) NOIP2012同余方程 NOIP2007统计数字 NOIP2013火柴排队 NOIP2013花匠 2016.06.05 Uva 组装电脑 12124 - Assemble Uva 派 (Pie,NWERC 2006,LA 3635) 2016.06.19 Uva 网络(Network,Seoul 2007,LA 39…
A. Vitya in the Countryside time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Every summer Vitya comes to visit his grandmother in the countryside. This summer, he got a huge wart. Every gran…
Today at the lesson Vitya learned a very interesting function - mex. Mex of a sequence of numbers is the minimum non-negative number that is not present in the sequence as element. For example, mex([4, 33, 0, 1, 1, 5]) = 2 and mex([1, 2, 3]) = 0. Vit…
D. Vitya and Strange Lesson 题意 数列里有n个数,m次操作,每次给x,让n个数都异或上x.并输出数列的mex值. 题解 01字典树保存每个节点下面有几个数,然后当前总异或的是sw,则sw为1的位的节点左右孩子交换(不用真的交换).左孩子的值小于左边总节点数则mex在左子树,否则在右子树. 代码 const int N=531000;//3e5<2^19<N int sw=0; struct Trie{ int ch[N*20][2]; int cnt[N*20];…
D.Vitya and Strange Lesson(字典树) 题意: 给一个长度为\(n\)的非负整数序列,\(m\)次操作,每次先全局异或\(x\),再查询\(mex\) \(1<=n<=3e5\) \(0<=a_i<=3e5\) \(0<=x<=3e5\) 思路:求\(mex\)可以通过按从高位到低位建字典树,判断左子树是否满,若未满,贪心往走,否则往右走,这样查询是\(log\)的 现在就是异或修改,考虑x的第i位,若为1,则以第i-1层结点为根的左右子树都需要…
题意: Today at the lesson Vitya learned a very interesting function - mex. Mex of a sequence of numbers is the minimum non-negative number that is not present in the sequence as element. For example, mex([4, 33, 0, 1, 1, 5]) = 2 and mex([1, 2, 3]) = 0.…
因为抑或,一眼字典树 但是处理起来比较难 #include<iostream> #include<map> #include<iostream> #include<cstring> #include<cstdio> #include<set> #include<vector> #include<queue> #include<stack> #include<cmath> #include…
题目大意: 定义mex数为数组中第一个没有出现的非负整数.有m个操作,每个操作有一个x,将数组中所有的元素都异或x,然后询问当前的mex Input First line contains two integer numbers n and m (1 ≤ n, m ≤ 3·105) — number of elements in array and number of queries. Next line contains n integer numbers ai (0 ≤ ai ≤ 3·105…
题目链接 /* 异或只有两种情况,可以将序列放到01Tire树上做 在不异或的情况下在Tire上查找序列的mex很容易,从高位到低位 如果0位置上数没有满,则向0递归:否则向1 (0位置上的数都满了 即 其子树叶子节点都有值) 异或情况下 若x在当前位有1,则反转0/1继续走 由于异或具有结合率,异或一次求mex和异或多个数求原数列mex是一样的 故每次不需要修改原数列,las^=opt即可 注意需要去重 因为在判断某位置rt下的区间中的数都有时,需要num[rt],相同的数显然不能算(画个图)…
http://codeforces.com/contest/842/problem/D 树 二进制(路径,每个节点代表一位) #include <cstdio> #include <cstdlib> #include <cmath> #include <cstring> #include <time.h> #include <string> #include <set> #include <map> #incl…
http://codeforces.com/contest/842/problem/D 1.整体的数组是不用变的,比如数组a[]经过一次询问x后,然后再询问y,相当于询问x ^ y ^ a[i]后的mex值 2.假设所求的答案是k,询问的数字是x,那么对于每个元素a[i],有a[i] ^ x != k恒成立.因为k是一个a[i]^x后得到的新数组,一个不存在新数组的数.所以若a[i] ^ x = k,则k不会是答案. 3.两个数相异或的结果是唯一的,即z ^ x 是一个确定值. 那么要求答案k,…
#include <iostream> #include <cstdio> using namespace std; int s[2000005][2], cnt, n, m, x, uu, ans, dep[2000005], siz[2000005]; void ins(){ int u=0; for(int i=19; i>=0; i--){ int t=(x&(1<<i))>0; if(!s[u][t]) s[u][t] = ++cnt; u…
题目链接:http://codeforces.com/contest/842/problem/D 题解:像这种求一段异或什么的都可以考虑用字典树而且mex显然可以利用贪心+01字典树,和线段树差不多就是比较节点总数和有的数字数比较有限向左边转移. 然后这个异或其实可以利用一个数num与一个一个的x异或然后求异或的mex也是容易的只要判断当前二进制位是1那么左右节点拥有的数字数互换(不用真的互换 只要用转移体现出来就行了).这里的01字典树写法是类似线段树且利用递归的方法. #include <i…
给一个序列,每次操作对这个序列中的所有数异或一个x,问每次操作完以后整个序列的mex值. 做法是去重后构建01字典树,异或x就是对root加一个x的lazy标志,每次pushDown时如果lazy的这一位是1,则交换左右儿子.找mex的话只要每次往左走,如果左子树是满的,则往右走,并且加上左边相应造成的贡献.具体见代码: #include <bits/stdc++.h> using namespace std; ; typedef long long ll; int n, m; struct…