a-young-man-jrs

C++博客 联系 聚合 管理
  5 Posts :: 2 Stories :: 1 Comments :: 0 Trackbacks
http://sqybi.blogbus.com/logs/15221427.html

一个很古老但很有用的TopCoder教程,贴出来.因为不知道来源了,所以无法注明来源.
改了一下格式和里面一些内容,蓝色的部分是我大幅度更改的内容(似乎只有JRE的下载,已经实验,绝对可用).

1.基本规则
2.运行环境
3.注册与登陆
4.界面简介
5.练习
6.比赛
7.注意事项
8.代码编写

TopCoder(以下简写tc) URL: http://www.topcoder.com

1.基本规则
  tc的比赛规则归结起来就是一句话:75分钟做完3道难度递增的题。
  tc的每个用户(handle)都有自己的积分,从0-3000+不等。成绩越好,分数越高。比赛分为两个division。Div I和Div II。积分<1200或者unrated(即注册但还没参加过比赛的)参加Div II,>=1200的参加Div I。Div I的题要比Div II难许多。一般DivII的最后一题和Div I的第一或第二题是一样的。无论是Div I或Div II。三道题目的Score一般为250, 500和1000左右,视每次的难度略有浮动。个人积分(rating)的增减是根据你和别人在比赛中的score以及你们原来的rating决定的。tc的提交结合了ICPC和IOI的特点,即只能交一次,必须过所有数据并且得分与用时相关。tc每周有一次Single Round Match(SRM),每年两次大的比赛(有$)。

2.运行环境
  tc的客户端是一个java程序,所以需要jre( java runtime environment) 或者jdk( java development kit) 来运行。如果平时不写java程序的话,装jre就可以了。毕竟jdk比jre大一个数量级,下载慢。安装照着提示完成就行了。推荐使用1.4.1以后的版本,因为带了java web start,可以快速登陆。具体方法下一部分讲。
  sun公司主页上的JRE Version 6 Update 3(最新)下载地址:
  http://www.java.com/zh_CN/download/index.jsp

3.注册与登陆。
  点主页右上角的register注册,过程没什么好说的。
  注册好后就可以登陆了。有两种方法:
  a.点左侧的Launch Arena Applet
    点后弹出一个窗口,等一会后就出现一个Load Competition Arena的按纽。 点击就运行了客户端。注意不要把这个小窗口关掉,否则客户端会一并关了。这个方法在win2000下有时候会有问题,但是在98下是正常的。不推荐。
  b.通过java web start运行
    topcoder主页底部有一栏如下:
    ---------------------------------------------------------------------
    | Java Web Start                                                    |
    | Run the Arena as a Java Web Start Application                     |
    | JWS already installed? Load the Arena as a Java Application       |
    | Arena Plugins—Information and Downloads   ~~~~~~~~~~~~~~~~这里   |
    ---------------------------------------------------------------------
    把那个"Java Application"拖到桌面上建立一个快捷方式,以后双击就可以直接运行了。客户端启动后有一个窗口,填上申请的username和password,如果是用代理的话,把HTTP Tunneling选上。登陆后就到了主页面。

4.界面简介
  -----------------------------------------------------------------------
  |   Advertisements.............                                       |
  -----------------------------------------------------------------------
  | Main | Lobbies | Options | Practice Rooms | Active Contests | Help ||
  -----------------------------------------------------------------------
  |                                                 | Clock |           |
  -----------------------------------------------------------------------
  | Rating Key | Who's here |                 Chat Area                 |
  |     .      |            |                                           |
  |     .      |            |                                           |
  |     .      |            |                                           |
  |     .      |            |                                           |
  |     .      |            |                                           |
  |------------|            |                                           |
  |  MESSAGES  |            |                                           |
  |------------|            |                                           |
  |LEADER BOARD|            |                                           |
  |------------|            |                                           |
  |            |            |                                           |
  |            |            |-------------------------------------------|
  |            |            | >>_______________________________________ |
  -----------------------------------------------------------------------
                          (宽度太小,缩放了一下:)
  逐部分说明一下:
    Advertisements: No comment.
    Menus:
      Main里可以看在线名单和找人。
      Lobbies基本用不着,因为用户一般都在Chat Room 1
      Options里是一些选项和颜色设置。
      Practice Rooms里有大量的练习,都是以前比赛的题目
      Active Contests只有有比赛的时候才有用。
      Help里是....不用说了吧。
    Rating Key: handle的颜色是随着积分而改变的,这里显示了积分与颜色的关系。
    MESSAGES: 比赛的时候这里有注册提示和clarification。
    LEADER BOARD: 看每个room的最高分。
    Who's here: 当前room里的人。
    Chat Area: 聊天。

5.练习
  在Practice Rooms里随便选择一个room就可以进入practice了。
  界面与主页面稍有变化,但基本相同,略去不画。主要的变化就是Who's here分成了两块,多了一块Who's assigned。这块显示的是谁被分到了这个room。因为是练习区,所以只要是在这里打开过题的都算是assigned。而在正式比赛中room是由tc分配的。这里显示的是被分配到这个room的人。界面上还有一个变化是Chat Area顶上多了三块。最左边的是一个下拉菜单。里面有三个分值,选择后就可以打开相应的题目。中间的summary可以看这个room里每个人的提交情况。
  在practice room里只有coding phase。提交后要判的话需要自己选择Practice Options里的Run System Test。

6.比赛
  每次比赛(除了1年两次的大赛)都需要在赛前3小时-5分钟之间登陆注册方可参加,注册在Active Contest菜单的第一项。一般需要回答一道选择题(多半是调查)才能注册。到剩下5分钟的时候,注册终止,tc开始按照报名者的rating分配room。分配完成后,Active Contest菜单中Register一项变成Enter。选择后可以直接进入你被分配到的room。Active Contest菜单最下面还有一项暗色背景的Room子菜单,可以进入各个room溜达。进入自己room的时候一般离开始只有3分钟左右,静一下心就可以直接开始比赛了。
  coding phase的过程与practice基本相同。注意每题的得分是和用的时间相关,而时间是从你打开该题开始算的。所以一题做完后可以不急着打开下一题,先放松一下。
  75分钟的coding后是5分钟的intermission,这段时间是用来休息和聊天的。
  然后就是最刺激的15分钟challenge phase。打开summary,双击别人的各题Score可以打开那题的程序,如果觉得有错误就可以点左下的Challenge然后输入你认为他会错的数据,成功的话能得到50分,对方该题分数为0;而如果失败了,你会被减去50分。所以若不是考虑成熟或背水一战的话,最好不要随便Challenge。
  Challenge结束后就是System Test。这个过程一般比较慢,可以先走开做其他事。过20分钟再回来看结果。结果出来后再过一段时间就可以看到一系列message比如rating更新了,新的practice room建好了以及可以通过主页查看这次比赛的数据了。

7.注意事项
  a.主页上有一份日历,日历下面的More 2003 Match Dates点进去可以看到最近比赛的时间安排。注意当前我们的时间与他们刚好相差12小时,因此若时间是7月9日9:00 P.M.的话,这里是7月10日9:00 A.M. 还有要注意的是美国有夏令时,非夏令时的时候,还要再加1小时,就是7月10日10:00 A.M.。
  b.Practice Rooms里写的程序只要点SAVE就可以保存,下次login的时候还可以看到,但是比赛时候的程序必须Submit才可以在coding phase结束后保存(coding phase结束前还是只要SAVE就可以的)。
  c.若想cha别人的程序,自己必须是正分(0分也不行),所以若没有一题有正确的程序但有很好的数据的话,随便交一道看上去正确的程序,然后在challenge的时候快下手,就可以赚到了。
  d.客户端自带的编辑器只有基本的编辑功能和编译及测试功能(连自动缩进都没有)。所以若觉得不方便的话可以使用parser和plugin,tc主页最下面有plugin的连接。因为我没有用过,所以具体方法不详。
  e.tc的FAQ
    http://www.topcoder.com/?&t=support&c=index
  f.最后一条,千万不要作弊,会有严重的后果。

8.代码编写
  tc的程序都不用标准或文件输入和输出的,只要写一个类的一个成员函数。
  输入是参数,输出用return,所以需要stl中的vector和string。
  标准输出可以当调试用。

  比如这题:

  Problem Statement for LeaguePicks
 
  Problem Statement
    You and your friends are setting up a fantasy TopCoder league, where you choose coders to be on your team and score points in the league when any one of your coders wins their room or successfully challenges somebody, etc. To be fair, a system has been developed to choose the order in which picks are distributed. It works like this: first, lots are drawn to choose your position in the league. Then the player with the first position gets first pick, the second player gets second pick, all the way until the last player picks. Then the order reverses: the last player chooses again, then the next to last player, and so on, until you reach the first player again. Then the cycle repeats: the first position chooses again, then the second, and so on.
    For example: say you were in the third position on a 6 player league. You would get the 3rd pick, then you'd wait until the 10th pick (the order would be 1,2,you,4,5,6,6,5,4,you), and then the 15th pick, and so on until there were no more coders to choose. If there were 20 total picks, then you would get pick numbers 3,10,15.
    Not wanting to miss your chance at a pick, your goal is to write a program that tells you what pick numbers you have in the order that you have them. You will receive three ints indicating your position in the league(1 being the first position), the number of friends that are in the league with you, and the number of picks that are being divvied up among the league. You will return an int[] that indicates the picks that you receive in ascending order.

  Definition
    Class: LeaguePicks                         //要写的Class名
    Method: returnPicks                        //要写的Method名
    Parameters: int, int, int                  //输入参数
    Returns: vector <int>                      //返回
    Method signature: vector <int> returnPicks(int position, int friends, int picks) (be sure your method is public)
 
  Notes
  - Note that your position in the league and the pick numbers start at 1 and not 0. This should be clear from the examples.
 
  Constraints
  - position will be between 1 and friends inclusive.
  - friends will be between 1 and 40 inclusive.
  - picks will be between 1 and 40 * friends inclusive.
 
Examples
  略

样例程序:
#include <vector>
using namespace std;
class LeaguePicks //只需要这个类就可以了
{
public:
vector <int> returnPicks(int a,int b,int c) //需要这个method
{
   vector <int> ret;
   int i;
   if (c>=a) ret.push_back (a); else return ret;
   if (c>=2*b-a+1) ret.push_back(2*b-a+1);
   for (i=0;;i++)
      if (ret[i]+2*b<=c) ret.push_back(ret[i]+2*b);
      else return ret;
   return ret;
}
};

posted on 2009-05-21 14:44 神剑戎 阅读(544) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理