Fata7y Ya Warda! Druid (AKA Amr Alaa El-Deen) and little EOIers have finished their training and they are playing "Fatta7y ya warda!". It's a kids game when everyone holds hands with two other kids forming a circle, and they keep saying "Fa…
题目链接[http://www.spoj.com/problems/DRUIDEOI/en/] 题意:给出n个数,从1到n围城一个环(1和n相连),求每个数左边第一个比他大的第一个下标,右边第一个比他大的下标,若所有的值都没有i大输出-1,-1. 题解:为了构成一个环,把所有的数重复两遍即:1,2,3,4,5,1,2,3,4,5,分别从前到后和从后到前维护单调递减栈即可.注意下标. #include<bits/stdc++.h> using namespace std; ; int a[max…
题目 Source http://www.spoj.com/problems/DQUERY/en/ Description Given a sequence of n numbers a1, a2, ..., an and a number of d-queries. A d-query is a pair (i, j) (1 ≤ i ≤ j ≤ n). For each d-query (i, j), you have to return the number of distinct elem…
SPOJ - GSS3 Can you answer these queries III Description You are given a sequence A of N (N <= 50000) integers between -10000 and 10000. On this sequence you have to apply M (M <= 50000) operations: modify the i-th element in the sequence or for giv…
http://www.spoj.com/problems/SUBLEX/ 好难啊. 建出后缀自动机,然后在后缀自动机的每个状态上记录通过这个状态能走到的不同子串的数量.该状态能走到的所有状态的f值的和+1就是当前状态的f值. 最后对于询问的k,从root开始走顺便加加减减就可以了. #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int in() { int k =…
Time Limit: 1000MS Memory Limit: 1572864KB 64bit IO Format: %lld & %llu Description Being a completist and a simplist, kid Yang Zhe cannot solve but get Wrong Answer from most of the OI problems. And he refuse to write two program of same kind at…
题目 Source http://www.spoj.com/problems/TSUM/ Description You're given a sequence s of N distinct integers.Consider all the possible sums of three integers from the sequence at three different indicies.For each obtainable sum output the number of diff…
COT - Count on a tree #tree You are given a tree with N nodes.The tree nodes are numbered from 1 to N.Each node has an integer weight. We will ask you to perform the following operation: u v k : ask for the kth minimum weight on the path from node u …
Query on a tree Time Limit: 5000ms Memory Limit: 262144KB This problem will be judged on SPOJ. Original ID: QTREE64-bit integer IO format: %lld Java class name: Main Prev Submit Status Statistics Discuss Next Font Size: + - Type: None Graph…
http://www.spoj.com/problems/DISUBSTR/ 题意:求字符串不同子串的数目. #include <bits/stdc++.h> using namespace std; const int N=1005; void sort(int *x, int *y, int *sa, int n, int m) { static int c[N], i; for(i=0; i<m; ++i) c[i]=0; for(i=0; i<n; ++i) ++c[x[y…
DQUERY - D-query #sorting #tree English Vietnamese Given a sequence of n numbers a1, a2, ..., an and a number of d-queries. A d-query is a pair (i, j) (1 ≤ i ≤ j ≤ n). For each d-query (i, j), you have to return the number of distinct elements in the…