06 2013 档案
摘要:题目链接非常不容易的一道题,把每个点向右上构造一个矩形,将问题转化为重合矩形那个亮度最大,注意LL,注意排序。 1 #include <cstdio> 2 #include <cstring> 3 #include <string> 4 #include <algorithm> 5 using namespace std; 6 #define maxn 50100 7 #define lson l,m,rt<<1 8 #define rson m+1,r,rt<<1|1 9 #define LL __int64 10 st
阅读全文
摘要:题目链接虽然是看的别的人思路,但是做出来还是挺高兴的。首先求环上最大字段和,而且不能是含有全部元素。本来我的想法是n个元素变为2*n个元素那样做的,这样并不好弄。实际可以求出最小值,总和-最小,就可以求出,断开的情况了。然后线段树要单点更新,这种标记,以前遇到过,不过一直没有写过,注意总和好更新,整个这一段的结果也很好更新,最难想的就是左边 和右边标记的结果,具体看pushup代码。 1 #include <cstring> 2 #include <cstdio> 3 #include <string> 4 #include <iostream>
阅读全文
摘要:做了俩,rating涨了80。第二个题是关于身份证的模拟题,写的时间比较长,但是我认真检查了。。。第三个题是最短路,今天写了写,写的很繁琐,写的很多错。 1 #include <cstring> 2 #include <cstdio> 3 #include <string> 4 #include <iostream> 5 #include <algorithm> 6 #include <vector> 7 #include <queue> 8 using namespace std; 9 #define INF
阅读全文
摘要:题目链接二分求上界和下界,树状数组。注意特殊情况。 1 #include <cstring> 2 #include <cstdio> 3 #include <string> 4 #include <iostream> 5 #include <algorithm> 6 #include <vector> 7 using namespace std; 8 int p[100001]; 9 int o[100001]; 10 int stack[100001]; 11 int n; 12 int lowbit(int t) 13
阅读全文
摘要:题目链接注意题目中给的顺序是顺时针的,所以在数组中应该是倒着存的。左就是顺时针,右就是逆时针。各种调试之后,终于A了,很多种情况考虑情况。 1 #include <cstring> 2 #include <cstdio> 3 #include <string> 4 #include <iostream> 5 #include <algorithm> 6 #include <vector> 7 using namespace std; 8 char name[500001][11]; 9 int o[500001]; 10
阅读全文
摘要:题目链接居然没更新flag就交了,错了两次。。3个题,都是一个类型。 1 #include <cstring> 2 #include <cstdio> 3 #include <string> 4 #include <iostream> 5 #include <algorithm> 6 #include <vector> 7 using namespace std; 8 int o[5001]; 9 int flag[5001];10 int find(int x)11 {12 if(x == o[x]) return x;
阅读全文
摘要:题目链接经过宝哥的讲解,终于对这种问题有了进一步的理解。根据flag[x]和flag[y]求flag[tx]是最关键的了。0吃1,1吃2,2吃0.假设flag[tx] = X;那么X + flag[x] = flag[y] + 2 (当x吃y的时候) 1 #include <cstring> 2 #include <cstdio> 3 #include <string> 4 #include <iostream> 5 #include <algorithm> 6 #include <vector> 7 using name
阅读全文
摘要:题目链接这种类型的题目以前见过,今天第一次写,具体过程,还要慢慢理解。 1 #include <cstring> 2 #include <cstdio> 3 #include <string> 4 #include <iostream> 5 #include <algorithm> 6 #include <vector> 7 using namespace std; 8 int o[100001]; 9 int flag[100001];10 int find(int x)11 {12 if (x == o[x]) ret
阅读全文
摘要:Rating又跌了,第二个题,没想好就乱开始乱写了。。我写乱搞贪心,没过。。。如果总人数很多judge函数写的不好,DIV2数据很水,直接暴力就行。 1 #include <cstring> 2 #include <cstdio> 3 #include <string> 4 #include <iostream> 5 #include <algorithm> 6 #include <vector> 7 using namespace std; 8 vector<int>::iterator it; 9 int
阅读全文
摘要:题目链接找到最小的约数最多的。 1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 using namespace std; 5 #define LL __int64 6 LL ans,res,n; 7 int prime[16] = {1,2,3,5,7,11,13,17,19,23,29,31,37,41,43,47}; 8 //当前枚举到的数;枚举到的第K大的质因子;该数的约数个数;质因子个数上限。 9 void dfs(LL num,LL k,LL sum,int lim
阅读全文
摘要:题目链接非常无语的一个题,参考的HH大神的代码。离散化写的很神。 1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 using namespace std; 5 #define lson l , m ,rt<<1 6 #define rson m + 1, r, rt<<1|1 7 8 const int maxn = 21111; 9 int cnt; 10 bool hash[maxn]; 11 int x[maxn+30],y[maxn+30];
阅读全文
摘要:题目链接看了别人思路,逆序插入,然后就会发现只要为留出pos[i]个位置就行了。树状数组+二分求下界就好了。 1 #include <stdio.h> 2 #include <string.h> 3 #include <algorithm> 4 #include <iostream> 5 using namespace std; 6 #define N 200011 7 int pos[N]; 8 int p[N],n; 9 struct node10 {11 int val;12 int id;13 }num[N];14 int lowbit(
阅读全文
摘要:题目链接根据区间更新的模版改改。线段树真的很不熟悉,交了很多次。 1 #include <stdio.h> 2 #include <string.h> 3 #include <iostream> 4 using namespace std; 5 #define N 100001 6 #define LL __int64 7 int p[4*N],lz[4*N]; 8 void pushup(int rt) 9 {10 p[rt] = p[rt<<1]|p[rt<<1|1];11 }12 void pushdown(int rt)13
阅读全文