您的位置:首页 > 其它

关于Online Judge 的Tips

2010-11-26 23:03 99 查看
总体:

关于WA:

1、遇到持续WA的题目,上网搜索OJ名+题号,一般都可以得到对应的解答。一般,OJ本身也设有讨论平台。

2、有可能是Presentation Error。很大的可能,是 换行符 多打、少打的问题。UVA对这点很严格(比其他的OJ都要严格),很多的WA,其实都是这点共享的。(后面再次提了一次)

UVA:

1、外挂:

a) 有个很好的网站,是UVA OJ切题的必备法宝:http://felix-halim.net/uva/hunting.php

输入你的UVA用户名,可以立刻显示你的题目状态(有时候上UVA的网好萎……),你的总排名,给你的推荐题目(这点很好!!),etc。很实用的工具。(注:Steven
的弟弟写的。Steven是个很强的越南人:)希望下学期能上他的 CS2020。

b)UVA Toolkit:http://uvatoolkit.com/problemssolve.php

是个个人网站,主要提供对于Test Cases的正确output。不过,一个附件的好处是,题目都有Key Words,于是你可以按关键字检索自己想要的题目。个人没试过(上面felix给的那个推荐题目,已经很合适啦)。

2、关于注释:写注释是个很好的习惯,但UVA的编译器仿佛不支持 // 形式的注释……于是,我写了个小程序,用来在本机上删除“//”形式的注释,并把新文件命名为 *.c,而且允许用户输入 *.c,或者仅仅输入不含.c的部分~很实用。

(e.g.:比如,我的这个AC文件是424.c,我既可以输入424,也可以输入424.c)。

基于一个Assumption:每行的字符,不超过1000个。

代码:

#include <stdio.h>
int is_ended_c(char name[])
{
int n=strlen(name);
if(name[n-2]=='.' && name[n-1]=='c')	return 1;
return 0;
}
int main(){
FILE *in;
FILE *out;
char temp[100];
char name[100];
char line[1000];
char c,t;
int i;

printf("please give me the name of the file you want to submit for, /n");
printf("the name is *.c, but you don't have need to type in the .c /n name?: ");
scanf("%s",temp);strcpy(name,temp);
if(!is_ended_c(temp)){strcat(name,".c");}
else	temp[strlen(temp)-2]=0;	// make it not ended with .c
in=fopen(name,"r");
while(!in){	// in == null, which means didn't find the file
printf("%s not found, please make sure you've give me a correct name:",name);
scanf("%s",temp);strcpy(name,temp);
if(!is_ended_c(temp)){strcat(name,".c");}
in=fopen(name,"r");
}

// generate the output file name, assuming the name of the input file is *.c
strcpy(name,temp);
strcat(name,"_in.c");
out=fopen(name,"w");

printf("readed successfully, the file created is %s, the content:/n/n",name);

while((c=fgetc(in))!=EOF)
{
if(c!='/'){fputc(c,out);fputc(c,stdout);}
else
{
t=fgetc(in);
if(t==EOF)	{fputc(c,out);fputc(c,stdout);break;}
if(t!='/')	{fputc(c,out);fputc(c,stdout);fputc(t,out);fputc(t,stdout);}	// not commented
else{	// it's the comment
while((c=fgetc(in))!='/n' && c!=EOF);	// stop when it's the end of this line, or the EOF is met
fputc('/n',out);fputc('/n',stdout);
}
}
}

printf("Task finished, press anykey to exit.");

getch();
return 0;
}


3、如果UVA上持续WA,并且基本确定自己没错,是什么原因:

有可能是Presentation Error。很大的可能,是 换行符 多打、少打的问题。UVA对这点很严格(比其他的OJ都要严格),很多的WA,其实都是这点共享的。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: