USACO Trainng - 試題解題一覽
相關介紹
What's This
How To Start
題目中譯
NOCOW - USACO Training (簡)
USACO譯題のSGZOI鏡像站 (簡)
Section 1.1
Your Ride Is Here (ride)
Greedy Gift Givers (gift1)
Friday the Thirteenth (friday)
Broken Necklace (beads) - coming soon...
Your Ride Is Here (ride) - coming soon...
Section 1.2
Milking Cows (milk2) - coming soon...
Transformations (transform) - coming soon...
Name That Number (namenum) - coming soon...
Palindromic Squares (palsquare) - coming soon...
Dual Palindromes (dualpal) - coming soon...
Section 1.3
Mixing Milk (milk) - coming soon...
Barn Repair (barn1) - coming soon...
Calf Flac (calfflac) - coming soon...
Prime Cryptarithm (crypt1) - coming soon...
Section 1.4
Packing Rectangles (packrec) - coming soon...
The Clocks (clocks) - coming soon...
Arithmetic Progressions (ariprog) - coming soon...
Mother's Milk (milk3) - coming soon...
Section 1.5
Number Triangles (numtri) - coming soon...
Prime Palindromes (pprime) - coming soon...
SuperPrime Rib (sprime) - coming soon...
Checker Challenge (checker) - coming soon...
Section 2.1
The Castle (castle) - coming soon...
Ordered Fractions (frac1) - coming soon...
Sorting A Three-Valued Sequence (sort3) - coming soon...
Healthy Holsteins (holstein) - coming soon...
Hamming Codes (hamming) - coming soon...
Section 2.2
Preface Numbering (preface) - coming soon...
Subset Sums (subset) - coming soon...
Runaround Numbers (runround) - coming soon...
Party Lamps (lamps) - coming soon...
Section 2.3
The Longest Prefix (prefix) - coming soon...
Cow Pedigrees (nocows) - coming soon...
Zero Sum (zerosum) - coming soon...
Money Systems (money) - coming soon...
Controlling Companies (concom) - coming soon...
Section 2.4
The Tamworth Two (ttwo) - coming soon...
Overfencing (maze1) - coming soon...
Cow Tours (cowtour) - coming soon...
Bessie Come Home (comehome) - coming soon...
Fractions to Decimals (fracdec) - coming soon...
Section 3.1
Agri-Net (agrinet) - coming soon...
Score Inflation (inflate) - coming soon...
Humble Numbers (humble) - coming soon...
Shaping Regions (rect1) - coming soon...
Contact (contact) - coming soon...
Stamps (stamps) - coming soon...
Section 3.2
Factorials (fact4) - coming soon...
Stringsobits (kimbits) - coming soon...
Spinning Wheels (spin) - coming soon...
Feed Ratios (ratios) - coming soon...
Magic Squares (msquare) - coming soon...
Sweet Butter (butter) - coming soon...
Section 3.3
Riding The Fences (fence) - coming soon...
Shopping Offers (shopping) - coming soon...
Camelot (camelot) - coming soon...
Home on the Range (range) - coming soon...
A Game (game1) - coming soon...
Section 3.4
Closed Fences (fence4) - coming soon...
American Heritage (heritage) - coming soon...
Electric Fence (fence9) - coming soon...
Raucous Rockers (rockers) - coming soon...
Section 4.1
Beef McNuggets (nuggets) - coming soon...
Fence Rails (fence8) - coming soon...
Fence Loops (fence6) - coming soon...
Cryptcowgraphy (cryptcow) - coming soon...
Section 4.2
Drainage Ditches (ditch) - coming soon...
The Perfect Stall (stall4) - coming soon...
Job Processing (job) - coming soon...
Cowcycles (cowcycle) - coming soon...
Section 4.3
Buy Low, Buy Lower (buylow) - coming soon...
The Primes (prime3) - coming soon...
Street Race (race3) - coming soon...
Letter Game (lgame) - coming soon...
Section 4.4
Shuttle Puzzle (shuttle) - coming soon...
Pollutant Control (milk6) - coming soon...
Frame Up (frameup) - coming soon...
Section 5.1
Fencing the Cows (fc) - coming soon...
Starry Night (starry) - coming soon...
Musical Themes (theme) - coming soon...
Section 5.2
Snail Trail (snail) - coming soon...
Electric Fences (fence3) - coming soon...
Wisconsin Squares (wissqu) - coming soon...
Section 5.3
Milk Measuring (milk4) - coming soon...
Window Area (window) - coming soon...
Network of Schools (schlnet) - coming soon...
Big Barn (bigbrn) - coming soon...
Section 5.4
All Latin Squares (latin) - coming soon...
Canada Tour (tour) - coming soon...
Character Recognition (charrec) - coming soon...
Betsy's Tour (betsy) - coming soon...
TeleCowmunication (telecow) - coming soon...
Section 5.5
Picture (picture) - coming soon...
Hidden Passwords (hidden) - coming soon...
Two Five (twofive) - coming soon...
Section 6.1
Postal Vans (vans) - coming soon...
A Rectangular Barn (rectbarn) - coming soon...
Cow XOR (cowxor) - coming soon...
NOTICE
2月 13, 2009
【解題】Friday the Thirteenth
USACO Section 1.1 - Friday the Thirteenth
The Problem
Is Friday the 13th really an unusual event?
That is, does the 13th of the month land on a Friday less often than on any other day of the week? To answer this question, write a program that will compute the frequency that the 13th of each month lands on Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday over a given period of N years. The time period to test will be from January 1, 1900 to December 31, 1900+N-1 for a given number of years, N. N is non-negative and will not exceed 400.
There are few facts you need to know before you can solve this problem:
Don't just precompute the answers, either, please.
Program Name: friday
Input Format
One line with the integer N.
Output Format
Seven space separated integers on one line. These integers represent the number of times the 13th falls on Saturday, Sunday, Monday, Tuesday, ..., Friday.
Sample Input (file friday.in)
20
Sample Output (file friday.out)
36 33 34 33 35 35 34
解題思考
首先,既然我們已經知道,1900 年 1 月 1 日是星期一,那麼我們只需要求出:某日是從 1900 年 1 月 1 日開始的第幾天,將這個數字除以 7 所得到的餘數,就能夠知道那一天到底是星期幾(餘數 0 ~ 6 分別對應到星期天至星期一)。
所以,我利用迴圈,跑過從 1900 年到 1900 + n - 1 年中每一個月的 13 號(至於怎麼對應閏年,就照題目說的做吧),分別利用上面的方式得出「這個 13 號」是星期幾,並紀錄下來。
最後,依照星期六、星期日、星期一、星期二、星期三、星期四、星期五的順序輸出紀錄的結果,就可以了。
參考解答(C++)
The Problem
Is Friday the 13th really an unusual event?
That is, does the 13th of the month land on a Friday less often than on any other day of the week? To answer this question, write a program that will compute the frequency that the 13th of each month lands on Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday over a given period of N years. The time period to test will be from January 1, 1900 to December 31, 1900+N-1 for a given number of years, N. N is non-negative and will not exceed 400.
There are few facts you need to know before you can solve this problem:
- January 1, 1900 was on a Monday.
- Thirty days has September, April, June, and November, all the rest have 31 except for February which has 28 except in leap years when it has 29.
- Every year evenly divisible by 4 is a leap year (1992 = 4*498 so 1992 will be a leap year, but the year 1990 is not a leap year)
- The rule above does not hold for century years. Century years divisible by 400 are leap years, all other are not. Thus, the century years 1700, 1800, 1900 and 2100 are not leap years, but 2000 is a leap year.
Don't just precompute the answers, either, please.
Program Name: friday
Input Format
One line with the integer N.
Output Format
Seven space separated integers on one line. These integers represent the number of times the 13th falls on Saturday, Sunday, Monday, Tuesday, ..., Friday.
Sample Input (file friday.in)
20
Sample Output (file friday.out)
36 33 34 33 35 35 34
解題思考
首先,既然我們已經知道,1900 年 1 月 1 日是星期一,那麼我們只需要求出:某日是從 1900 年 1 月 1 日開始的第幾天,將這個數字除以 7 所得到的餘數,就能夠知道那一天到底是星期幾(餘數 0 ~ 6 分別對應到星期天至星期一)。
所以,我利用迴圈,跑過從 1900 年到 1900 + n - 1 年中每一個月的 13 號(至於怎麼對應閏年,就照題目說的做吧),分別利用上面的方式得出「這個 13 號」是星期幾,並紀錄下來。
最後,依照星期六、星期日、星期一、星期二、星期三、星期四、星期五的順序輸出紀錄的結果,就可以了。
參考解答(C++)
#include <fstream>
using namespace std;
inline bool isLeapYear(int year);
int main(void)
{
ifstream in("friday.in", ios::in);
ofstream out("friday.out", ios::out);
int n;
in >> n;
in.close();
int totalDay = 13, time[12];
memset(time, 0, sizeof(time));
for (int i = 0; i < n; i++)
{
for (int j = 1; j <= 12; j++)
{
time[totalDay % 7]++;
// 計算從 1900 年 1 月 1 日到 (1900 + i) 年 j 月 13 日共有幾天
int day;
switch (j)
{
case 2:
day = (isLeapYear(1900 + i)) ? 29 : 28;
break;
case 4:
case 6:
case 9:
case 11:
day = 30;
break;
default:
day = 31;
}
totalDay += day;
}
}
out << time[6];
for (int i = 0; i < 6; i++)
{
out << " " << time[i];
}
out << endl;
out.close();
return 0;
}
inline bool isLeapYear(int year)
{
// 返回傳入的年份是否為閏年
return (year % 100 != 0 && year % 4 == 0) || (year % 400 == 0);
}
【解題】Greedy Gift Givers
USACO Section 1.1 - Greedy Gift Givers
The Problem
A group of NP (2 ≤ NP ≤ 10) uniquely named friends has decided to exchange gifts of money. Each of these friends might or might not give some money to any or all of the other friends. Likewise, each friend might or might not receive money from any or all of the other friends. Your goal in this problem is to deduce how much more money each person gives than they receive.
The rules for gift-giving are potentially different than you might expect. Each person sets aside a certain amount of money to give and divides this money evenly among all those to whom he or she is giving a gift. No fractional money is available, so dividing 3 among 2 friends would be 1 each for the friends with 1 left over -- that 1 left over stays in the giver's "account".
In any group of friends, some people are more giving than others (or at least may have more acquaintances) and some people have more money than others.
Given a group of friends, no one of whom has a name longer than 14 characters, the money each person in the group spends on gifts, and a (sub)list of friends to whom each person gives gifts, determine how much more (or less) each person in the group gives than they receive.
Important Note
The grader machine is a Linux machine that uses standard Unix conventions: end of line is a single character often known as '\n'. This differs from Windows, which ends lines with two charcters, '\n' and '\r'. Do not let your program get trapped by this!
Program Name: gift1
Input Format
Line 1: The single integer, NP
Lines 2..NP+1: Each line contains the name of a group member
Lines NP+2..end: NP groups of lines organized like this:
The first line in the group tells the person's name who will be giving gifts.
The second line in the group contains two numbers: The initial amount of money (in the range 0..2000) to be divided up into gifts by the giver and then the number of people to whom the giver will give gifts, NGi (0 ≤ NGi ≤ NP-1).
If NGi is nonzero, each of the next NGi lines lists the the name of a recipient of a gift.
Output Format
The output is NP lines, each with the name of a person followed by a single blank followed by the net gain or loss (final_money_value - initial_money_value) for that person. The names should be printed in the same order they appear on line 2 of the input. All gifts are integers. Each person gives the same integer amount of money to each friend to whom any money is given, and gives as much as possible that meets this constraint. Any money not given is kept by the giver.
Sample Input (file gift1.in)
5
dave
laura
owen
vick
amr
dave
200 3
laura
owen
vick
owen
500 1
dave
amr
150 2
vick
owen
laura
0 2
amr
vick
vick
0 0
Sample Output (file gift1.out)
dave 302
laura 66
owen -359
vick 141
amr -150
解題思考
首先,我宣告了一個包含了「姓名」(name)與「收支金額」(money)的結構體。在讀入所有人的名字,存入結構體中的 name 成員之後,同時將其 money 成員歸零(在起初,並未有任何收入或支出)。
接著讀入所有的「送禮紀錄」之後,則將送禮者的 money 成員減去送禮花費的金額。但是要注意,由於送禮的金額是「盡可能多給」,且能夠「平分給所有人」的金額。所以實際花費的金額,應該是每個人的「持有金額」減去「此金額除以收禮者人數的餘數」。
然後將每個收禮者的 money 成員加上收到的禮物金額,也就是「送禮金額」除以「收禮人數」。
讀完所有送禮紀錄後,直接將每個人的 name 與 money 成員成對輸出,就是題目要求的結果了。
參考解答(C++)
The Problem
A group of NP (2 ≤ NP ≤ 10) uniquely named friends has decided to exchange gifts of money. Each of these friends might or might not give some money to any or all of the other friends. Likewise, each friend might or might not receive money from any or all of the other friends. Your goal in this problem is to deduce how much more money each person gives than they receive.
The rules for gift-giving are potentially different than you might expect. Each person sets aside a certain amount of money to give and divides this money evenly among all those to whom he or she is giving a gift. No fractional money is available, so dividing 3 among 2 friends would be 1 each for the friends with 1 left over -- that 1 left over stays in the giver's "account".
In any group of friends, some people are more giving than others (or at least may have more acquaintances) and some people have more money than others.
Given a group of friends, no one of whom has a name longer than 14 characters, the money each person in the group spends on gifts, and a (sub)list of friends to whom each person gives gifts, determine how much more (or less) each person in the group gives than they receive.
Important Note
The grader machine is a Linux machine that uses standard Unix conventions: end of line is a single character often known as '\n'. This differs from Windows, which ends lines with two charcters, '\n' and '\r'. Do not let your program get trapped by this!
Program Name: gift1
Input Format
Line 1: The single integer, NP
Lines 2..NP+1: Each line contains the name of a group member
Lines NP+2..end: NP groups of lines organized like this:
The first line in the group tells the person's name who will be giving gifts.
The second line in the group contains two numbers: The initial amount of money (in the range 0..2000) to be divided up into gifts by the giver and then the number of people to whom the giver will give gifts, NGi (0 ≤ NGi ≤ NP-1).
If NGi is nonzero, each of the next NGi lines lists the the name of a recipient of a gift.
Output Format
The output is NP lines, each with the name of a person followed by a single blank followed by the net gain or loss (final_money_value - initial_money_value) for that person. The names should be printed in the same order they appear on line 2 of the input. All gifts are integers. Each person gives the same integer amount of money to each friend to whom any money is given, and gives as much as possible that meets this constraint. Any money not given is kept by the giver.
Sample Input (file gift1.in)
5
dave
laura
owen
vick
amr
dave
200 3
laura
owen
vick
owen
500 1
dave
amr
150 2
vick
owen
laura
0 2
amr
vick
vick
0 0
Sample Output (file gift1.out)
dave 302
laura 66
owen -359
vick 141
amr -150
解題思考
首先,我宣告了一個包含了「姓名」(name)與「收支金額」(money)的結構體。在讀入所有人的名字,存入結構體中的 name 成員之後,同時將其 money 成員歸零(在起初,並未有任何收入或支出)。
接著讀入所有的「送禮紀錄」之後,則將送禮者的 money 成員減去送禮花費的金額。但是要注意,由於送禮的金額是「盡可能多給」,且能夠「平分給所有人」的金額。所以實際花費的金額,應該是每個人的「持有金額」減去「此金額除以收禮者人數的餘數」。
然後將每個收禮者的 money 成員加上收到的禮物金額,也就是「送禮金額」除以「收禮人數」。
讀完所有送禮紀錄後,直接將每個人的 name 與 money 成員成對輸出,就是題目要求的結果了。
參考解答(C++)
#include <fstream>
#include <cstring>
using namespace std;
struct person
{
char name[13];
int money;
};
int main(void)
{
ifstream in("gift1.in", ios::in);
ofstream out("gift1.out", ios::out);
int NP;
in >> NP;
person *people = new person[NP];
for (int i = 0; i < NP; i++)
{
in >> people[i].name;
people[i].money = 0;
}
for (int i = 0; i < NP; i++)
{
char name[13];
int money, number;
in >> name >> money >> number;
// 忽略不送任何禮物的情況
if (money && number)
{
for (int j = 0; j < NP; j++)
{
if (!strcmp(people[j].name, name))
{
// 將自身金額扣除支出金額
people[j].money -= money - money % number;
break;
}
}
}
for (int j = 0; j < number; j++)
{
char recipient[13];
in >> recipient;
// 將禮物收受者金額加上禮物金額
for (int k = 0; k < NP; k++)
{
if (!strcmp(people[k].name, recipient))
{
people[k].money += money / number;
break;
}
}
}
}
in.close();
for (int i = 0; i < NP; i++)
{
out << people[i].name << " " << people[i].money << endl;
}
out.close();
return 0;
}
2月 11, 2009
【解題】Your Ride Is Here
USACO Section 1.1 - Your Ride Is Here
The Problem
It is a well-known fact that behind every good comet is a UFO. These UFOs often come to collect loyal supporters from here on Earth. Unfortunately, they only have room to pick up one group of followers on each trip. They do, however, let the groups know ahead of time which will be picked up for each comet by a clever scheme: they pick a name for the comet which, along with the name of the group, can be used to determine if it is a particular group's turn to go (who do you think names the comets?). The details of the matching scheme are given below; your job is to write a program which takes the names of a group and a comet and then determines whether the group should go with the UFO behind that comet.
Both the name of the group and the name of the comet are converted into a number in the following manner: the final number is just the product of all the letters in the name, where "A" is 1 and "Z" is 26. For instance, the group "USACO" would be 21 * 19 * 1 * 3 * 15 = 17955. If the group's number mod 47 is the same as the comet's number mod 47, then you need to tell the group to get ready! (Remember that "a mod b" is the remainder left over after dividing a by b; 34 mod 10 is 4.)
Write a program which reads in the name of the comet and the name of the group and figures out whether according to the above scheme the names are a match, printing "GO" if they match and "STAY" if not. The names of the groups and the comets will be a string of capital letters with no spaces or punctuation, up to 6 characters long.
Examples:
Program Name: ride
Input Format
Line 1: An upper case character string of length 1..6 that is the name of the comet.
Line 2: An upper case character string of length 1..6 that is the name of the group.
NOTE: The input file has a newline at the end of each line but does not have a "return". Sometimes, programmers code for the Windows paradigm of "return" followed by "newline"; don't do that! Use simple input routines like "readln" (for Pascal) and, for C/C++, "fscanf" and "fid>>string".
Output Format
A single line containing either the word "GO" or the word "STAY".
Sample Input (file ride.in)
COMETQ
HVNGAT
Sample Output (file ride.out)
GO
解題思考
這題基本上不難,大概是給我們「試水溫」、熟悉一下 USACO 的上傳步驟吧。
根據題意,分別將上下兩行的每個英文字母 A - Z 轉換成數字 1 - 26 之後相乘。
接著求出這兩個數字除以 47 的餘數,若是相等則輸出 "GO",不相等則輸出 "STAY"。完成。
參考解答(C++)
The Problem
It is a well-known fact that behind every good comet is a UFO. These UFOs often come to collect loyal supporters from here on Earth. Unfortunately, they only have room to pick up one group of followers on each trip. They do, however, let the groups know ahead of time which will be picked up for each comet by a clever scheme: they pick a name for the comet which, along with the name of the group, can be used to determine if it is a particular group's turn to go (who do you think names the comets?). The details of the matching scheme are given below; your job is to write a program which takes the names of a group and a comet and then determines whether the group should go with the UFO behind that comet.
Both the name of the group and the name of the comet are converted into a number in the following manner: the final number is just the product of all the letters in the name, where "A" is 1 and "Z" is 26. For instance, the group "USACO" would be 21 * 19 * 1 * 3 * 15 = 17955. If the group's number mod 47 is the same as the comet's number mod 47, then you need to tell the group to get ready! (Remember that "a mod b" is the remainder left over after dividing a by b; 34 mod 10 is 4.)
Write a program which reads in the name of the comet and the name of the group and figures out whether according to the above scheme the names are a match, printing "GO" if they match and "STAY" if not. The names of the groups and the comets will be a string of capital letters with no spaces or punctuation, up to 6 characters long.
Examples:
| Input | Output |
| COMETQ HVNGAT |
GO |
| ABSTAR USACO |
STAY |
Program Name: ride
Input Format
Line 1: An upper case character string of length 1..6 that is the name of the comet.
Line 2: An upper case character string of length 1..6 that is the name of the group.
NOTE: The input file has a newline at the end of each line but does not have a "return". Sometimes, programmers code for the Windows paradigm of "return" followed by "newline"; don't do that! Use simple input routines like "readln" (for Pascal) and, for C/C++, "fscanf" and "fid>>string".
Output Format
A single line containing either the word "GO" or the word "STAY".
Sample Input (file ride.in)
COMETQ
HVNGAT
Sample Output (file ride.out)
GO
解題思考
這題基本上不難,大概是給我們「試水溫」、熟悉一下 USACO 的上傳步驟吧。
根據題意,分別將上下兩行的每個英文字母 A - Z 轉換成數字 1 - 26 之後相乘。
接著求出這兩個數字除以 47 的餘數,若是相等則輸出 "GO",不相等則輸出 "STAY"。完成。
參考解答(C++)
#include <fstream>
using namespace std;
int main(void)
{
ifstream in("ride.in", ios::in);
ofstream out("ride.out", ios::out);
char cometName[7], groupName[7];
in >> cometName >> groupName;
in.close();
// 將彗星的名字轉換成數字
int cometNumber = 1;
for (int i = 0; cometName[i] != '\0'; i++)
{
cometNumber *= cometName[i] - 'A' + 1;
}
// 將團體的名字轉換成數字
int groupNumber = 1;
for (int i = 0; groupName[i] != '\0'; i++)
{
groupNumber *= groupName[i] - 'A' + 1;
}
out << ((cometNumber % 47 == groupNumber % 47) ? "GO" : "STAY") << endl;
out.close();
return 0;
}
1月 30, 2009
【介紹】USACO - How To Start
延續前一篇的介紹,現在讓我們看看要如何申請一組 USACO Trainng 的帳號,並開始我們的解題之路!

首先,來到 USACO Trainng 的首頁,點選 "Register here for a username/password" 開始註冊。

接著就依照欄位,把資料填完就可以了。
選填欄位可以先全部不填,等收到認證信登入之後,網站會再要求你把需要的選填資料填完。

註冊成功之後,應該會看到如上圖的畫面。
接著到註冊用的電子郵件信箱收信之後,應該會收到一封主旨為 "USACO Training Registration Info with Password" 的信。內文如下:

然後回到首頁,用剛剛信上寫著的帳號密碼登入。

如果剛剛沒有填國家的話,應該會顯示上圖的畫面。
找到自己的國家名稱,點下去就對了。

如果剛剛沒有填中學畢業年的話,應該會顯示上圖的畫面。
基本上,網頁上面有說:假如不想洩漏(我是懶得查XD)畢業年的話,直接填入 "9999" 即可。

接著就能進入上圖的畫面了。
不過記得,由於密碼是網站給你的,為了避免忘記密碼,請記得點選上方的 "Change Password" 修改密碼。

假如點選了 "Change Password",照著填上去按下 "Submit" 送出就好了。

回到剛才的頁面。
一開始還不能開始寫題目,我們需要先點選 "TEXT Introduction",看官方的介紹文章。

大致上是介紹 USACO 跟這個網站的內容。有興趣的人可以仔細看看。

回到剛才的頁面,發現 Section 1.1 的文字變成連結了。
接著請點選 "TEXT Submitting Solutions",裡面會告訴你 USACO Trainng 上傳程式的方式與程式格式。
簡單來說,就是上傳的程式裡,前幾行必須用註解標記一些相關資訊。以 C++ 為例,你需要在開頭加入:
並記得在 main() 主函式中加入 "return 0;"。
基本上裡面寫得很仔細,一定要先仔細讀過。

接著來實際演練一遍。
在文章裡把它的範例程式複製下來(記得將 ID 修改成自己的),上傳程式原始碼就可以了。

接著會顯示上傳後的結果。
假如結果有錯,網頁會列出你錯誤的那筆測試資料與正確答案,以方便除錯。
假如都沒有錯誤,網頁就會列出所有測試資料,與你的程式跑每筆測試資料所花的時間。

終於,我們可以來正式挑戰 USACO Trainng 的題目了。


題目內文裡面,會標示程式名稱、輸入檔名稱與輸出檔名稱,記得不要搞錯了。

當解出題目之後,題目連結後面會出現一個 [ANALYSIS] 的連結。

點進去之後,就是官方的題目分析,與參考的程式碼了。

當解完所有 Section 1.1 的題目後,才可以開始寫 Section 1.2,所以寫題目只能照著章節跑。
只要能解完 Section 1 到 Section 6 的題目,你就成功闖關 USACO Trainng 了!祝各位好運。
首先,來到 USACO Trainng 的首頁,點選 "Register here for a username/password" 開始註冊。
接著就依照欄位,把資料填完就可以了。
選填欄位可以先全部不填,等收到認證信登入之後,網站會再要求你把需要的選填資料填完。
註冊成功之後,應該會看到如上圖的畫面。
接著到註冊用的電子郵件信箱收信之後,應該會收到一封主旨為 "USACO Training Registration Info with Password" 的信。內文如下:
Here is the information you need to participate in the USACO Training Program:
* Use http://ace.delos.com/usacogate as the gateway URL.
* Your permanent personalized username and password are:
Name: (你的名字)
UserName: (你的帳號)
Password: (你的密碼)
Please save this UserName and Password as they are permanently assigned to you.
Rob Kolstad, Head Coach
USA Computing Olympiad * kolstad@ace.delos.com * 877-753-3567
然後回到首頁,用剛剛信上寫著的帳號密碼登入。
如果剛剛沒有填國家的話,應該會顯示上圖的畫面。
找到自己的國家名稱,點下去就對了。
如果剛剛沒有填中學畢業年的話,應該會顯示上圖的畫面。
基本上,網頁上面有說:假如不想洩漏(我是懶得查XD)畢業年的話,直接填入 "9999" 即可。
接著就能進入上圖的畫面了。
不過記得,由於密碼是網站給你的,為了避免忘記密碼,請記得點選上方的 "Change Password" 修改密碼。
假如點選了 "Change Password",照著填上去按下 "Submit" 送出就好了。
回到剛才的頁面。
一開始還不能開始寫題目,我們需要先點選 "TEXT Introduction",看官方的介紹文章。
大致上是介紹 USACO 跟這個網站的內容。有興趣的人可以仔細看看。
回到剛才的頁面,發現 Section 1.1 的文字變成連結了。
接著請點選 "TEXT Submitting Solutions",裡面會告訴你 USACO Trainng 上傳程式的方式與程式格式。
簡單來說,就是上傳的程式裡,前幾行必須用註解標記一些相關資訊。以 C++ 為例,你需要在開頭加入:
/* ID: (你的帳號) PROG: (題目名稱) LANG: C++ */
並記得在 main() 主函式中加入 "return 0;"。
基本上裡面寫得很仔細,一定要先仔細讀過。
接著來實際演練一遍。
在文章裡把它的範例程式複製下來(記得將 ID 修改成自己的),上傳程式原始碼就可以了。
接著會顯示上傳後的結果。
假如結果有錯,網頁會列出你錯誤的那筆測試資料與正確答案,以方便除錯。
假如都沒有錯誤,網頁就會列出所有測試資料,與你的程式跑每筆測試資料所花的時間。
終於,我們可以來正式挑戰 USACO Trainng 的題目了。
題目內文裡面,會標示程式名稱、輸入檔名稱與輸出檔名稱,記得不要搞錯了。
當解出題目之後,題目連結後面會出現一個 [ANALYSIS] 的連結。
點進去之後,就是官方的題目分析,與參考的程式碼了。
當解完所有 Section 1.1 的題目後,才可以開始寫 Section 1.2,所以寫題目只能照著章節跑。
只要能解完 Section 1 到 Section 6 的題目,你就成功闖關 USACO Trainng 了!祝各位好運。
1月 29, 2009
【介紹】USACO - What's This
USACO (United States of America Computing Olympiad,美國資訊奧林匹亞)是美國為其中學生所舉辦的程式設計競賽,能使用的程式語言包含 C、C++、Java 以及 Pascal。
USACO 舉辦的目的在於訓練美國中學生的邏輯思考與解決問題的能力,並從中選拔出每年 IOI (International Olympiad in Informatics,奧林匹亞資訊學科) 的參賽選手。而為了確實培訓將來要參加 IOI 的國手,USACO 特別建立了所謂的 USACO Training。

USACO Training 是一個線上的網路題庫,主要是用來訓練程式設計、活用演算法與資料結構的能力。題目的內容五花八門,涵蓋了各式各樣的問題。且 USACO Training 題目依照難易度,由簡到難共分為 6 個章節,必須以章節順序依次將題目完成。
除了循序漸進之外,USACO Training 還提供了許多程式設計相關的教學文章,像是貪婪演算法(Greedy Algorithm)、深度優先搜尋(Depth-First Search,DFS)、廣度優先搜尋(Breadth-First search,BFS)、動態規劃(Dynamic Programming,DP)等等。
看完教學文章之後,再利用題庫中的題目做練習,學習的效果相當顯著。若是程式有錯誤,網站還會列出程式的錯誤訊息、或是錯誤的那筆測試資料與正確答案的對照,以便於除錯。而在解出題目之後,USACO Training 還有詳細的題目分析講解與參考程式。
貼心的是,遇上某些太難的題目,USACO Training 還會提供一些小提示。只要順著提示的引導,往往就可以寫出那一題的答案了。
總而言之,我覺得 USACO Training 的題目其實還滿有意思的。在一邊寫的同時,感覺也學到了不少東西。所以新年新希望,就是能夠將 USACO Training 中的題目全部寫完囉(笑)。
以下是一些相關網站及參考資料,有興趣的人可以參閱:
.USA Computing Olympiad
.USACO Training Program Gateway
.USACO Contest Gateway
.United States of America Computing Olympiad - Wikipedia
USACO 舉辦的目的在於訓練美國中學生的邏輯思考與解決問題的能力,並從中選拔出每年 IOI (International Olympiad in Informatics,奧林匹亞資訊學科) 的參賽選手。而為了確實培訓將來要參加 IOI 的國手,USACO 特別建立了所謂的 USACO Training。
USACO Training 是一個線上的網路題庫,主要是用來訓練程式設計、活用演算法與資料結構的能力。題目的內容五花八門,涵蓋了各式各樣的問題。且 USACO Training 題目依照難易度,由簡到難共分為 6 個章節,必須以章節順序依次將題目完成。
除了循序漸進之外,USACO Training 還提供了許多程式設計相關的教學文章,像是貪婪演算法(Greedy Algorithm)、深度優先搜尋(Depth-First Search,DFS)、廣度優先搜尋(Breadth-First search,BFS)、動態規劃(Dynamic Programming,DP)等等。
看完教學文章之後,再利用題庫中的題目做練習,學習的效果相當顯著。若是程式有錯誤,網站還會列出程式的錯誤訊息、或是錯誤的那筆測試資料與正確答案的對照,以便於除錯。而在解出題目之後,USACO Training 還有詳細的題目分析講解與參考程式。
貼心的是,遇上某些太難的題目,USACO Training 還會提供一些小提示。只要順著提示的引導,往往就可以寫出那一題的答案了。
總而言之,我覺得 USACO Training 的題目其實還滿有意思的。在一邊寫的同時,感覺也學到了不少東西。所以新年新希望,就是能夠將 USACO Training 中的題目全部寫完囉(笑)。
以下是一些相關網站及參考資料,有興趣的人可以參閱:
.USA Computing Olympiad
.USACO Training Program Gateway
.USACO Contest Gateway
.United States of America Computing Olympiad - Wikipedia
訂閱:
文章 (Atom)
Infinite Loop © 2008. Blog design by Blogcut | Converted by Fernandooo1 (Randomness)