08 2013 档案
摘要:这道又是submission error ,先存下档。 1 #include 2 #include 3 const int maxnode=4000*1000+10; 4 int ch[maxnode][62]; 5 int val[62]; 6 int sz; 7 int index(char ch) 8 { 9 if(ch>='0'&&ch'A'&&ch1) ans+=val[i];49 ans+=((n-1)*n)/2;50 printf("Case %d: %d\n",kcase++,ans);5
阅读全文
摘要:递推式:d[i]=sum(d[i+len[x]])这道题的数据真狗血,改了一点就过了。 1 #include 2 #include 3 #include 4 using namespace std; 5 const int maxnode=4000*100+10; 6 const int mod=20071027; 7 const int maxn=300000 + 10; 8 const int maxw=4000 + 10; 9 char ss[maxn];10 char s[110];11 int d[maxn];12 int len[maxw];13 int ch[maxnode][2
阅读全文
摘要:因为查询的前缀字典可能不含有,这点没考虑清楚就码了,太粗心了,因为case只有一个,很多初始化操作都不需要了。 1 #include 2 #include 3 const int maxnode=500000; 4 int ch[maxnode][26]; 5 int val[maxnode]; 6 int sz; 7 void insert(char *s) 8 { 9 int u=0,len=strlen(s);10 for(int i=0;i<len;i++)11 {12 int c=s[i]-'a';13 if(!ch[u][c]...
阅读全文
摘要:只能说数据比较水而已结点应该得开到le10的,刚开始那么开的时候,编译出错了,说是数组开太大了,后来改成le6就过了。 1 #include 2 #include 3 const int maxnode=1e4; 4 int ch[maxnode][10]; 5 int val[maxnode]; 6 int sz; 7 void insert(char *s) 8 { 9 int u=0,n=strlen(s);10 for(int i=0;i=2) return 0;29 return 1;30 }31 int main()32 {33 int t;34 ...
阅读全文
摘要:线段树单点更新 因为CASE之间的换行WA了两次 1 #include 2 #include 3 const int maxn=200000+5; 4 int sum[maxn>1;18 build(l,m,rt>1;30 if(x>1;41 int ret=0;42 if(Lm) ret+=query(L,R,m+1,r,rt<<1|1);44 return ret;45 }46 int main()47 {48 int n;49 while(scanf("%d",&n)&&n)50 {51 if(CASE!=1...
阅读全文
摘要:线段树加二分查找 1 #include 2 #include 3 #include 4 using namespace std; 5 const int maxn=50001; 6 const int INF=100000; 7 int sum[maxn>1; 36 build(l,m,rt>1; 46 sum[rt>1; 71 if(Lm) update(L,R,v,m+1,r,rt>1; 87 int ret=0; 88 if(Lm) ret+=query(L,R,m+1,r,rtlen-query(a,n,1,n,1))120...
阅读全文
摘要:low_bound() 1 int lower_bound(int *A,int x,int y,int v) 2 { 3 int m; 4 while(x>1; 7 if(A[m]>=v) y=m; 8 else x=m+1; 9 }10 return x;11 }
阅读全文
摘要:好题。 1 #include 2 #include 3 #include 4 using namespace std; 5 int CASE=1; 6 const int maxn=500000+5; 7 typedef long long LL; 8 typedef pair Interval; 9 int qL,qR; 10 LL s[maxn]; 11 Interval max_sub[maxnsum(b)?a:b; 26 } 27 void build(int l,int r,int rt) 28 { 29 if(l==r) 30 { 31 m...
阅读全文
摘要:这道题很狗血啊 赋值的时候那个v是大于等于0来着,主要考察区间赋值和更新,pushdown同时要有两个操作。代码如下: 1 #include 2 #include 3 #include 4 using namespace std; 5 const int maxn=1000000+5; 6 const int INF=1000000009; 7 int sum[maxn=0) 23 { 24 add[rt>1; 52 build(l,m,rt>1; 68 if(Lm) update(L,R,inc,m+1,r,rt>1; 84 if(Lm...
阅读全文
摘要:利用递推关系构建矩阵 然后矩阵快速幂 1 #include 2 #include 3 typedef long long LL; 4 const int mod=1000000007; 5 struct matrix 6 { 7 LL m[5][5]; 8 matrix(){memset(m,0,sizeof(m));} 9 matrix operator*(const matrix &a)const10 {11 matrix tmp;12 for(int i=0;i<5;i++)13 for(int j=...
阅读全文
摘要:构建概率矩阵,然后矩阵快速幂,直接输出答案。 1 #include 2 #include 3 #include 4 using namespace std; 5 int n,m,k; 6 vector g[201]; 7 struct matrix 8 { 9 float m[201][201];10 matrix(){memset(m,0,sizeof(m));}11 matrix operator *(const matrix &a)const12 {13 matrix tmp;14 for(int i=0;i<n;i++)1...
阅读全文
摘要:第一道RMQ就因为vector没有清空而WA了。 1 #include 2 #include 3 #include 4 using namespace std; 5 const int maxn=100000+5; 6 vector interval[maxn]; 7 int s[maxn]; 8 int value[maxn]; 9 int count[maxn];10 int num[maxn];11 int left[maxn];12 int right[maxn];13 int n,m;14 int d[maxn][100];15 int RMQ(int L,int R)16 {17
阅读全文
摘要://相同元素编号大较大 这么就可以避免处理有重复元素的情况。 1 #include 2 #include 3 #include 4 using namespace std; 5 const int maxn=500000+5; 6 struct item 7 { 8 int num; 9 int id;10 bool operator a.id;13 return num>a.num;14 }15 }s[maxn];16 int n;17 int c[maxn];18 int lowbit(int x)19 {20 return x&-x...
阅读全文
摘要:1 #include 2 #include 3 #include 4 using namespace std; 5 const int maxn=100000+5; 6 int c[maxn]; 7 int ans[maxn]; 8 struct pos 9 {10 int s,e;11 int id;12 bool operator s;15 return a.e0)26 {27 ret+=c[x];28 x-=lowbit(x);29 }30 return ret;31 }32 void ad...
阅读全文
摘要:1 #include 2 #include 3 #include 4 using namespace std; 5 const int maxn=15000+5; 6 const int maxd=32000+5; 7 int c[maxd]; 8 int ans[maxn]; 9 int lowbit(int x)10 {11 return x&-x;12 }13 int sum(int x)14 {15 int ret=0;16 while(x>0)17 {18 ret+=c[x];19 x-=lowbit(x);20 ...
阅读全文
摘要:1 #include 2 #include 3 #include 4 using namespace std; 5 const int maxn=100000+5; 6 struct edge 7 { 8 int v; 9 edge *next; 10 }; 11 edge *g[maxn]; 12 edge mall[2*maxn]; 13 edge *tmp; 14 int c[maxn]; 15 int s[maxn]; 16 int e[maxn]; 17 int vis[maxn]; 18 int cnt; 19 int n; 20 int top...
阅读全文
摘要:1 #include 2 #include 3 #include 4 using namespace std; 5 const int maxn=1000010+5; 6 int c[maxn]; 7 int n,m,k; 8 struct pos 9 {10 int e,w;11 bool operator a.e;14 return w>a.w;15 }16 }p[maxn];17 int lowbit(int x)18 {19 return x&-x;20 }21 int sum(int x)22 {23 int ret=0;24 ...
阅读全文
摘要:1 #include 2 #include 3 const int maxn=1024+5; 4 int s[maxn][maxn]; 5 int n; 6 int lowbit(int x) 7 { 8 return x&-x; 9 }10 long long sum(int x,int y)11 {12 long long ret=0;13 for(int i=x;i>0;i-=lowbit(i))14 for(int j=y;j>0;j-=lowbit(j))15 ret+=s[i][j];16 return ret;1...
阅读全文
摘要:1 #include 2 #include 3 const int maxn=1000+5; 4 int n,m; 5 int s[maxn][maxn]; 6 int lowbit(int x) 7 { 8 return x&-x; 9 }10 int sum(int x,int y)11 {12 int ret=0;13 for(int i=x;i>0;i-=lowbit(i))14 for(int j=y;j>0;j-=lowbit(j))15 ret+=s[i][j];16 return ret;17 }18 voi...
阅读全文
摘要:1 #include 2 #include 3 #include 4 using namespace std; 5 const int maxn=20000+5; 6 int dis[maxn]; 7 int num[maxn]; 8 int n; 9 struct COW10 {11 int vol,x;12 bool operator 0)25 {26 ret+=c[x];27 x-=lowbit(x);28 }29 return ret;30 }31 void add(int *c,int x,int inc,in...
阅读全文
摘要:数据量较大 卡了好几次超时 看了别人的报告 说是可以把电话号码转成整数,大概就是这么做的。 1 #include 2 #include 3 #include 4 using namespace std; 5 const int maxn=200000; 6 char s[500]; 7 char key[26]={'2','2','2','3','3','3','4','4','4','5','5','5'
阅读全文
浙公网安备 33010602011771号