O(n^3)的时间复杂度,改了半天交了二三十遍,TLE到死,实在没办法了…… 跪求指点!!! #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> using namespace std; ; << ; int mat[MAXN][MAXN]; int SubSum[MAXN][MAXN]; int tempS[MAXN]; int N, K; i…
离散化 枚举行 扫描横坐标 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #define inf 0x7fffffff using namespace std; struct cc { int x,y,val; }; cc pp[1010]; int k,line[1010],x[1010],cur; int _max,_min; int ma…
题目 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 =…