题目链接: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…
链接:[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…
题目大意:月亮从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…
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…
参考自: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. 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…
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/135/B 题意:给8个点 判断能否用 4个点构成正方形,另外4个点构成 矩形. 输出 第一行是正方形 ,第二行是矩形. 我的思路:用了4个for循环 枚举四个点, 用向量判断,四个点构成 六条边,如果这六条边里, 有四条边 与他们垂直的边有两个,就说明是矩形,在这个基础上,有 2条边 与他们垂直的边有一个. 说明是正方形. #include<iostream> #include<cstdio>…
   ZOJ1015 题意简述:给定一个无向图,判断是否存在一个长度大于3的环路,且其上没有弦(连接环上不同两点的边且不在环上). 命题等价于该图是否存在完美消除序列. 所谓完美消除序列:在 vi,vi+1,...vn vi与之后与vi相邻的点构成一个团(完全子图). 求完美消除序列的MCS算法.倒序给点标号,标号为i的点出现在序列的第i项.对每个顶点i,维护标号label[i],表示标号的度,每次选择标号最大的点标号.用堆加速. 求出了完美消除序列后,只要判断这个序列是否合法就可以得出结论.…
题目链接 /* 异或只有两种情况,可以将序列放到01Tire树上做 在不异或的情况下在Tire上查找序列的mex很容易,从高位到低位 如果0位置上数没有满,则向0递归:否则向1 (0位置上的数都满了 即 其子树叶子节点都有值) 异或情况下 若x在当前位有1,则反转0/1继续走 由于异或具有结合率,异或一次求mex和异或多个数求原数列mex是一样的 故每次不需要修改原数列,las^=opt即可 注意需要去重 因为在判断某位置rt下的区间中的数都有时,需要num[rt],相同的数显然不能算(画个图)…
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…
题目 如题. 题解 从序列第一个大于根节点的值往后都是右子树,判断右子树是否都大于根节点. 然后递归判断左右子树是否是BST 代码 class TreeNode { int val = 0; TreeNode left = null; TreeNode right = null; public TreeNode(int val) { this.val = val; } } public class VerifySeqOfBST { public static void main(String[]…
剑指 Offer 33. 二叉搜索树的后序遍历序列 Offer_33 题目详情 题解分析 本题需要注意的是,这是基于一颗二叉排序树的题目,根据排序二叉树的定义,中序遍历序列就是数据从小到大的排序序列. 这里有很多的细节问题,特别是在递归时,需要注意递归的出口和判断条件. 解法一:传统的方法 package com.walegarrett.offer; /** * @Author WaleGarrett * @Date 2021/2/1 16:45 */ import java.util.Arra…
D. Vitaly and Cycle       time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output After Vitaly was expelled from the university, he became interested in the graph theory. Vitaly especially liked th…
最后一个元素是 根节点. 左子树的元素都小于根节点,右子树都大于根节点 然后递归判断 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 class Solution { public:     bool VerifySquenceOfBST(vector<int> sequence) {         int size=sequ…
版本1:C++ class Solution { public: bool VerifySquenceOfBST(vector<int> sequence) { ) return false; ,j; ]; // 根节点 vector<int> leftTree, rightTree; while (sequence[i] < root){ // 找出左子树的范围 0 ~ i-1 leftTree.push_back(sequence[i]); // 将左子树存入一个vect…
蛋疼的比赛,当天忘了做了,做的模拟,太久没怎么做题了,然后C题这么简单的思路却一直卡到死,期间看了下D然后随便猜了下,暴力了下就过了. A.找一个能被t整除的n位数,那么除了<=10以外,其他都可以用长度为n的10或100,1000 ... 来往上加几个数而得到 #include <iostream> #include <stdio.h> #include <set> #include <algorithm> #include <string.h…
题目链接: https://codeforces.com/contest/1150/problem/D 题意: 给出长度为$n$的字符串,和$q$次询问 每次询问是,给$x$宗教增加一个字符$key$,或者让$x$宗教的字符串长度减一 问是否给原字符串染色,每个字符只能染上一种颜色,把相同颜色字符串按顺序取出刚好是每个宗教的字符串 数据范围: $1 \leq n \leq 100\,000$$1 \leq q \leq 1000$ 分析: 定义状态$DP[x][y][z]$,为考虑1号宗教字符串…
题目大意: 定义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…
import java.util.Scanner; public class test02 { public static void main(String[] args) { Scanner in = new Scanner(System.in); while (in.hasNext()) { String s = in.nextLine(); System.out.println(HuiWen(s)); } } public static boolean HuiWen(String s) {…
CF978B File Name [分析]:设置计数器cnt,计数x的个数:遇到非x,若cnt>=3的话累加多出的个数,计数器清零:若最后cnt>=3说明没遇到非x无法清零,那后部分就都是x,输出ans+=cnt-2 [代码]: #include<bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; #define ms(a,b) memset(a,b,sizeof(a)) #define rep(i,a,b…
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;…
用了两场比赛上Div 1感觉自己好腊鸡的说...以下是这两场比赛的部分题解(不得不说有个黄学长来抱大腿还是非常爽的) Round #372 : Div 2 A:Crazy Computer 题意:给定N个输入和一个时间长度M,每次输入屏幕上增加一个字符,若两个输入间隔大于M则屏幕上的字符会被清空,问结束时屏幕上还有多少个字符 直接模拟没有什么好说的 代码: #include<cstdio> #include<iostream> #include<cstring> #in…
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了. 最后,只…
考完复变之后沉迷联盟不能自拔...明天就开始抢救计组 ... B 一个人装错了键帽 选择几个pair 把pair里面的键帽交换 并且每个键帽最多可以换一次 给出按键序列和输出序列 判断是否可以 如果可以输出pair 因为每个键帽最多可以换一次 所以如果错了 一定是一一对应的 于是设定一个表存每个键帽对应的实际字母 需要注意的是 ac cc 这种情况下是 -1 很多人wa在了test14 C 在一个格子图里给出一个路径 里面有UDLR四种移动方向 问 我在格子路径里面最少选几个点 可以让我沿着格子…
在实验室通宵 一边做水题一边准备随时躲起来以免被门卫大爷巡查发现..结果居然没来.. 本来以为可以加几分变个颜色..结果挂了CD...状态有点差...思维不太活跃 沉迷暴力不能自拔 D 给出n个长方体 两个长方体 如果有一面完全相同 可以粘上变成一个 在一个长方体中可以切割出一个球体 选择1或2个长方体以得到最大的球体 输出选择的编号 一开始没看范围打了一个n^2的暴力 超时后相出了map配On的算法 由于比较暴力的判断 写了六个复制粘贴..漫长的debug之后过了pretest之后还是wa在了…