POJ 3263 差分+set判重】的更多相关文章

题意: 思路: 对于每一个区间 [a,b] [a+1,b-1]肯定是比a,b低至少1的 因为题目要求最大值 所以就直接差分一下 搞之 (复杂度 O(n)) Discuss里说有重复的数据 用set判一下重就好了复杂度O(nlogn) //By SiriusRen #include <set> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; int N…
题意: 初始状态固定(朝上的全是W,空格位置输入给出),输入初始状态的空格位置,和最终状态朝上的位置,输出要多少步才能移动到,超过30步输出-1. 简析: 每一个格子有6种状态,分别是 0WRB, 1WBR, 2RWB, 3RBW, 4BRW, 5BWR (上前后 对应的颜色) 由于只给出了终态朝上的颜色,其他的不知道,所以终态真正应该有256种,对于这个可以用一次dfs全部枚举出. 一. 搜索策略的问题 单向搜索的话,平均一下,大概每次也有3个状态,30层的话,复杂度太高,放弃. A*的话,考…
只需不断维护相对值的前缀就能得到解 这种思想第一次是在树状数组区间更新那里看到的,由于题目要求是1~n所以直接可以用前缀和维护 注意不能直接-1 +1 还有POJ的数据..要不是书里有提谁知道会这么毒瘤 /*H E A D*/ int delta[maxn]; map<P,int> vis; int main(){ int n,I,h,r,a,b; while(~iin(n)){ I=read();h=read();r=read(); memset(delta,0,sizeof delta);…
Sum It Up Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Submission(s) : 4   Accepted Submission(s) : 1 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description Given a specified total t and…
思路: 呃呃 暴搜+打表 暴搜的程序::稳稳的TLE+MLE (但是我们可以用来打表) 然后我们就可以打表过了 hiahiahia 可以证明最小的那个数不会超过200(怎么证明的我也不知道),然后就直接判重就好了 打表: 打表的程序: // by SiriusRen #include <queue> #include <cstdio> #include <algorithm> using namespace std; queue<pair<int,int&g…
题意:给出m个数字,要求组合成能够被n整除的最小十进制数. 分析:用到了余数判重,在这里我详细的解释了.其它就没有什么了. #include<cstdio> #include<cmath> #include<cstring> #include<queue> #include<algorithm> using namespace std; ; ; struct Node{ int pre; int r; int d; }; int vis[MAXN…
题意:给定 n 个点,每个点都可以和另一个点相连,问你共有多少种不同斜率的直线. 析:那就直接暴力好了,反正数也不大,用set判重就好,注意斜率不存在的情况. 代码如下: #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <iostream> #include <cstring> #include <set> #…
题意: 思路: 搜+判重 嗯搞定 (听说有好多人用7个for写得-.) //By SiriusRen #include <bitset> #include <cstdio>0 using namespace std; bitset<134217728>bit; char s[17][17],vis[17][17],xx[]={1,-1,0,0},yy[]={0,0,1,-1}; int ans; bool check(int x,int y){ for(int i=0;…
题目链接:http://poj.org/problem?id=3087 Shuffle'm Up Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 12305   Accepted: 5708 Description A common pastime for poker players at a poker table is to shuffle stacks of chips. Shuffling chips is per…
题目传送门 题意:一个图按照变成指定的图,问最少操作步数 分析:状态转移简单,主要是在图的存储以及判重问题,原来队列里装二维数组内存也可以,判重用神奇的hash技术 #include <bits/stdc++.h> using namespace std; const int MOD = 1e6 + 7; struct Point { int ch[5][9]; int x[4], y[4]; int step; }; bool vis[MOD]; int ha; int get_hash(i…