USACO

download USACO

If you can't read please download the document

Transcript of USACO

USACO

USACO

Elite 2008 January Competition USACO Contest Analysis and Data3

BRONZE PROBLEMS3

Costume Party [Neal Wu, 2007]3

Election Time [Jeffrey Wang, 2007]5

iCow [Jeffrey Wang, 2008]7

SILVER PROBLEMS9

Cow Contest [Neal Wu, 2007]9

Running [Neal Wu, 2007]11

Telephone Lines [Paul Christiano, 2007]13

GOLD PROBLEMS16

Haybale Guessing [Brian Dean, 2003]16

Artificial Lake [Matt McCutchen, 2006]19

Cell Phone Network [Jeffrey Wang, 2007]23

Special 2007 Chinese Competition contest26

GOLD PROBLEMS26

Summing Sums [Neal Wu, 2007]26

The Bovine Accordion and Banjo Orchestra [Lei Huang, 2007]31

Treasure [Yang Yi, 2007]35

Elite 2007 December Competition contest41

BRONZE PROBLEMS41

Bookshelf [Neal Wu, 2007]42

Bookshelf 2 [Neal Wu, 2007]44

Card Stacking [Jeffrey Wang, 2007]46

SILVER PROBLEMS49

Charm Bracelet [Kolstad/Cox, 2006]49

Building Roads [Richard Ho, 2007]53

Mud Puddles [Jeffrey Wang, 2007]56

GOLD PROBLEMS61

Sightseeing Cows [Reid Barton, 2007]61

Gourmet Grazers [Alex Schwendner, 2007]65

Best Cow Line, Gold [Christos Tzamos, 2007]68

Elite 2007 November Competition contest71

BRONZE PROBLEMS71

Exploration [Jeffrey Wang, 2007]71

Speed Reading [Jeffrey Wang, 2007]74

Avoid The Lakes [Jeffrey Wang, 2007]76

SILVER PROBLEMS78

Cow Hurdles [Neal Wu, 2007]78

Milking Time [Jeffrey Wang, 2007]81

Best Cow Line [Christos Tzamos, 2007]84

GOLD PROBLEMS88

Telephone Wire [Jeffrey Wang, 2007]88

Cow Relays [Erik Bernhardsson, 2003]90

Sunscreen [Russ Cox, 2001]93

Elite 2008 January Competition USACO Contest Analysis and Data

BRONZE PROBLEMS

*****************************************************************************

Costume Party [Neal Wu, 2007]

It's Halloween! Farmer John is taking the cows to a costume party, but unfortunately he only has one costume. The costume fits precisely two cows with a length of S (1 play #2 21/2 = 10, leftover = 1

11 0 18 -> play #3 ...

This program is a "pure programming" task. It requires nothing more than the implementation of a set of rules. The example even showed how one of the potentially troublesome rules actually worked.

The program below is commented to show how each step is performed. The only potentially tricky part is the use of two variables for the distribution: one to count how many pieces get distributed and the second to say where they go. The second variable is the trick for implementing the "Don't redistribute back to the currently playing song" rule.

#include

#include

void main() {

int bestrate, bestj, i, j, k, n, t, r[1000+1];

int evenlydistribute, leftover;

FILE *fin = fopen ("icow.in", "r");

FILE *fout = fopen ("icow.out", "w");

fscanf (fin, "%d %d", &n, &t);

for (i = 0; i < n; i++)

fscanf (fin, "%d", &r[i]);

for (i = 0; i < t; i++) { /* play t songs */

/* find highest rated song */

bestrate = -1;

for (j = 0; j < n; j++) {

if (r[j] > bestrate) { /* best, lowest index */

bestj = j;

bestrate = r[j];

}

}

fprintf (fout, "%d\n", bestj+1); /* play it */

evenlydistribute = r[bestj]/(n-1);

leftover = r[bestj] % (n-1);

r[bestj] = 0;

for (j = 0; j < n; j++)

if (j != bestj)

r[j] += evenlydistribute;

for (k = j = 0; j < leftover; j++, k++) {

if (j == bestj) k++;

r[k]++;

}

}

}

SILVER PROBLEMS

**********************************************************************

Cow Contest [Neal Wu, 2007]

N (1 > k;

int u, v, w;

for (int i = 0; i < ee; ++i) {

fin >> u >> v >> w;

u--;

v--;

a[u].push_back (v);

b[u].push_back (w);

a[v].push_back (u);

b[v].push_back (w);

e[i + 1] = w;

}

sort (e, e + 1 + ee);

Bfs (0);

if (!mark[0]) {

fout