Cena以及Lemon SpecialJudge的姿势
Jan 23, 2015 03:47:09 PM
这能算是普及?只是自己留一个存档.
有需要的就来自己脑补吧.
UPD:留一个lemon的对应参数说明:
Special Judge参数传送说明:
argv[1]: 标准输入文件
argv[2]: 选手输出文件
argv[3]: 标准输出文件
argv[4]: 本测试点满分
argv[5]: 分数输出文件(必须创建),仅一行,包含一个非负整数,表示得分。
argv[6]: 额外信息文件(可以不创建)
#include <cstdio> #include <cstring> #include <cstdlib> FILE *fscore, *freport, *fstd, *fin, *fout; inline void getScore(int x) { fprintf(fscore, "%d", x); } char s[2010], output[2010], tmp[1000000], *o = tmp; inline int Judge() { fscanf(fin, "%s", s); int len = strlen(s); fscanf(fout, "%s", output); int len_out = strlen(output); int std_len; fscanf(fstd, "%d", &std_len); if (len_out != std_len) return 1; register int i, j, k, p, q; for(i = 0; i < len_out; ++i) if (output[i] != '$' && output[i] != '*' && !(output[i] >= 'a' && output[i] <= 'z')) return 2; if (output[len_out - 1] != '$') return 2; for(i = 0; i < len_out; ) { if (!(output[i] >= 'a' && output[i] <= 'z')) return 2; for(j = i; output[j] != '$'; ++j); for(k = i; output[k] != '*' && output[k] != '$'; ++k); for(p = k; p <= j; ++p) if (output[p] != '$' && output[p] != '*') return 2; for(p = 1; p <= j - k + 1; ++p) for(q = i; q < k; ++q) *o++ = output[q]; i = j + 1; } int outputlen = o - tmp; if (outputlen != len) return 3; for(i = 0; i < len; ++i) if (tmp[i] != s[i]) return 3; return 0; } int main(int argc, char *argv[]) { fscore = fopen("score.log", "w"); freport = fopen("report.log", "w"); fstd = fopen(argv[2], "r"); //测试点标准输出文件 fin = fopen("compress.in", "r"); fout = fopen("compress.out", "r"); //用户输入、输出文件 if (!fout) { getScore(0); fprintf(freport, "Empty File!"); } else { int res = Judge(); if (res == 0) getScore(10), fprintf(freport, "Right Output!"); else if (res == 1) getScore(0), fprintf(freport, "Wrong Length!"); else if (res == 2) getScore(0), fprintf(freport, "Wrong Format!"); else if (res == 3) getScore(0), fprintf(freport, "Wrong Change!"); } fclose(fscore); fclose(freport); return 0; }
#include<bits/stdc++.h> FILE *fscore,*freport,*fstd,*fin,*fout; inline void GetScore(int d){ fprintf(fscore,"%d",d); } inline void End(){ fclose(fscore),fclose(freport); } int d[1010],x[1000010],y[1000010]; inline void work(int a,int b){ d[b]-=d[a],d[a]*=2; } int main(int argc,char*argv[]){ fscore=fopen(argv[5],"w");//得分文件 freport=fopen(argv[6],"w");//报告文件 fstd=fopen(argv[3],"r");//标准输出 fin=fopen(argv[1],"r");//标准输入 fout=fopen(argv[2],"r");//用户输出 int stdans;fscanf(fstd,"%d",&stdans); int yourans; if(fscanf(fout,"%d",&yourans)==0){ fprintf(freport,"No output."); GetScore(0); End();return 0; } if(stdans==-1){ if(yourans!=-1){ fprintf(freport,"No solution but you output an ans"); GetScore(0); End();return 0; } else{ fprintf(freport,"OK"),GetScore(10); End();return 0; } } else{ if(yourans==-1){ fprintf(freport,"There exists some solutions but you output no ans"); GetScore(0); End();return 0; } else if(yourans<0){ fprintf(freport,"Wrong:T<0"); GetScore(0); End();return 0; } else if(yourans>1000000){ fprintf(freport,"Too many operates"); GetScore(0); End();return 0; } else{ int n;register int i; fscanf(fin,"%d",&n); for(i=1;i<=n;++i)fscanf(fin,"%d",&d[i]); for(i=1;i<=yourans;++i){ if(fscanf(fout,"%d%d",&x[i],&y[i])!=2){ fprintf(freport,"output Not enough"); GetScore(0); End();return 0; } } int cash; if(fscanf(fout,"%d",&cash)==1){ fprintf(freport,"Too many output"); GetScore(0); End();return 0; } for(i=1;i<=yourans;++i){ if(x[i]==y[i]){ fprintf(freport,"Wrong at Line%d:x=y",i+1); GetScore(0); End();return 0; } else if(d[x[i]]>d[y[i]]){ fprintf(freport,"Wrong at Line%d:a[x]>a[y]",i+1); GetScore(0); End();return 0; } else work(x[i],y[i]); } int last=0; for(i=1;i<=n;++i)if(d[i]>0)++last; if(last==2){ fprintf(freport,"OK"),GetScore(10); End();return 0; } else{ fprintf(freport,"yourlast=%d,and it's larger then 2",last),GetScore(0); End();return 0; } } } return 0; }
[开新坑]对于后缀自动机的一些理解
Jan 12, 2015 03:44:00 PM
感觉单纯地从"后缀自动机"的角度来入手并不是非常合理.因为我们懂得很多"后缀自动机"的性质,但却并不清楚"后缀自动机"在本质上是什么.
让我们从后缀树说起.
2015.01.04集训总结
Jan 04, 2015 08:04:53 PM
Task#1 Contest
面对三道傻逼题本沙茶妥妥爆零.大家一起喊出来我弱不弱,弱不弱?
T1题目大意:傻逼题,大家通过代码来猜测什么题目吧.(多带了一个\(log\)结果没有超时,反而由于空间问题被卡了2MB内存,艹!)
#include<cstdio> #include<cstring> #include<cctype> #include<iostream> #include<algorithm> using namespace std; #define N 100010 struct Node{ int l,r,siz; }S[N*20];int cnt; int Newv(int last,int tl,int tr,int ins){ int q=++cnt;S[q]=S[last],++S[q].siz;if(tl==tr)return q; int mid=(tl+tr)>>1; if(ins<=mid)S[q].l=Newv(S[last].l,tl,mid,ins);else S[q].r=Newv(S[last].r,mid+1,tr,ins); return q; } int Query(int q,int tl,int tr,int dl,int dr){ if(dl<=tl&&tr<=dr)return S[q].siz; int mid=(tl+tr)>>1; if(dl>mid)return Query(S[q].r,mid+1,tr,dl,dr); else if(dr<=mid)return Query(S[q].l,tl,mid,dl,dr); else return Query(S[q].l,tl,mid,dl,mid)+Query(S[q].r,mid+1,tr,mid+1,dr); } struct Case{ int x,y; bool operator<(const Case&B)const{return x<B.x;} }C[N]; int p[N],q[N],root[N]; int main(){ freopen("permutation.in","r",stdin),freopen("permutation.out","w",stdout); int n;cin>>n;register int i,j; for(i=1;i<=n;++i)scanf("%d",&p[i]),C[p[i]].x=i;for(i=1;i<=n;++i)scanf("%d",&q[i]),C[q[i]].y=i; sort(C+1,C+n+1); for(i=1;i<=n;++i)root[i]=Newv(root[i-1],1,n,C[i].y); int lans=0,a,b,c,d,aa,bb,cc,dd,q;scanf("%d",&q); while(q--){ scanf("%d%d%d%d",&a,&b,&c,&d); aa=(a-1+lans)%n+1,bb=(b-1+lans)%n+1,cc=(c-1+lans)%n+1,dd=(d-1+lans)%n+1; a=min(aa,bb),b=max(aa,bb),c=min(cc,dd),d=max(cc,dd); printf("%d\n",(lans=Query(root[b],1,n,c,d)-Query(root[a-1],1,n,c,d)+1)-1); }return 0; fclose(stdin),fclose(stdout);return 0; }
T2:见下面的链接
http://wyfcyx.is-programmer.com/posts/75155.html
T3:见下面的链接
http://wyfcyx.is-programmer.com/posts/75156.html
Task#2 后缀数组及其应用
现在没时间,等我找到特别有意思的题目来做吧~~~
JDFZOJ上的USACO月赛题目目前存在的BUG
Dec 23, 2014 09:59:22 PM
刷到哪里更到哪里。
Bronze:
Silver:
Gold:
2567:提交答案
2586:需要SPJ
2607:需要SPJ
2655:需要SPJ
2664&1013:需要SPJ