acm icpc 2008 aizu

54
ACM ICPC 2008 Aizu Yoshihisa Nitta Chief Judge) Tsuda College

Upload: arama

Post on 11-Jan-2016

43 views

Category:

Documents


7 download

DESCRIPTION

ACM ICPC 2008 Aizu. Yoshihisa Nitta  ( Chief Judge) Tsuda College. Problem Set. Plan to prepare problems. Each team will solve at least one problem. Each problem will be solved by at least one team. No team will solve all the problems. ×. △. ○. Problem A: Grey Area. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: ACM ICPC 2008  Aizu

ACM ICPC 2008 Aizu

Yoshihisa Nitta ( Chief Judge)Tsuda College

Page 2: ACM ICPC 2008  Aizu

Problem SetNo Title Domain Level

A Grey Area Specification 1

B Expected Allowance Specification 1

C Stopped Watches Combination 2

D Digits on the Floor Graph 2.5

E Spherical Mirrors Geometry 2.5

F Traveling Cube Route search 3

G Search for Concatenated Strings String Match 3.5

H Top Spinning Geometry & Simulation 4

I Common Polynomial Formula manipulation 4

J Zigzag Geometry 4

Page 3: ACM ICPC 2008  Aizu

Plan to prepare problems

• Each team will solve at least one problem.

• Each problem will be solved by at least one team.

• No team will solve all the problems.

△×

Page 4: ACM ICPC 2008  Aizu

Problem A: Grey Area

• Estimate ink consumption for printing histogram• Each bar is drawn monotonically• Darkness of each bar is decreased from left to right

Correct team 34Submit 48

Histogram

Page 5: ACM ICPC 2008  Aizu

A: How to Solve

• 2 pass processing required

Count up and Classify• Number of Categories

are determinedEstimate ink consumption

Bar’s darkness

)1/(*0.10.1 ynumCategorigrey

Page 6: ACM ICPC 2008  Aizu

A: Example

Category Quantity Darkness

0-9 5 1.0

10-19 3 0.66667

20-29 1 0.33333

30-39 1 0.0

1 2 3 4 516 17 182930

Data Interval=10 Table of Frequency Distribution

Histogram

Page 7: ACM ICPC 2008  Aizu

Problem B: Expected Allowance

• Count up occurrence of each sum of pips of n dice.

• Pip of dice is between 1 and m• Calculate

Correct team 32Submit 35

mn

s

ypossibilitks*

1

)1,max(

Page 8: ACM ICPC 2008  Aizu

B: Count up occurrence

Page 9: ACM ICPC 2008  Aizu

B: Count up Occurrence

Sum 0 1 2 3 4 5 6 7 8 9 10 11 12

Occurrence 1 0 0 0 0 0 0 0 0 0 0 0 0

Sum 0 1 2 3 4 5 6 7 8 9 10 11 12

Occurrence 0 1 1 1 1 1 1 0 0 0 0 0 0

1st die:pim=1 2 3 4 5 6

0 die

1 die

Page 10: ACM ICPC 2008  Aizu

B: Count up Occurrence

Sum 0 1 2 3 4 5 6 7 8 9 10 11 12

Occurrence 0 1 1 1 1 1 1 0 0 0 0 0 0

1st die 1 die

Sum 0 1 2 3 4 5 6 7 8 9 10 11 12

Occurrence 0 0 0 0 0 0 0 0 0 0 0 0 0

2nd die:init

2 diceSum 0 1 2 3 4 5 6 7 8 9 10 11 12

Occurrence 0 0 1 1 1 1 1 1 0 0 0 0 0

2nd die:pip=1 +

Page 11: ACM ICPC 2008  Aizu

B: Count up Occurrence

Sum 0 1 2 3 4 5 6 7 8 9 10 11 12

Occurrence 0 1 1 1 1 1 1 0 0 0 0 0 0

1st die

2nd die:pip<=1Sum 0 1 2 3 4 5 6 7 8 9 10 11 12

Occurrence 0 0 1 1 1 1 1 1 0 0 0 0 0

1 die

2 diceSum 0 1 2 3 4 5 6 7 8 9 10 11 12

Occurrence 0 0 1 2 2 2 2 2 2 0 0 0 0

2nd die:pip=2 +

Page 12: ACM ICPC 2008  Aizu

B: Count up Occurrence

Sum 0 1 2 3 4 5 6 7 8 9 10 11 12

Occurrence 0 1 1 1 1 1 1 0 0 0 0 0 0

1st die

2nd die:pip<=2

1 die

2 dice

Sum 0 1 2 3 4 5 6 7 8 9 10 11 12

Occurrence 0 0 1 2 2 2 2 2 2 0 0 0 0

Sum 0 1 2 3 4 5 6 7 8 9 10 11 12

Occurrence 0 0 1 2 3 3 3 3 3 1 0 0 0

2nd die:pip=3 +

Page 13: ACM ICPC 2008  Aizu

Problem C: Stopped Watches

• Search the appropriate interpretation of watches.

Correct team 20Submit 23

Page 14: ACM ICPC 2008  Aizu

C:Relations between h and m

125

5

mhh

Page 15: ACM ICPC 2008  Aizu

C: Search Space

• Permutations of (s,t,u) equals 3! = 6• For each permutation of (s,t,u), (h,m,second)

is assigned and checked.• for given h and m, only 12 ways of i between 0 and 59 satisfies

12

55

imihih

7212!3 ways interpretation (for each clock)

Page 16: ACM ICPC 2008  Aizu

Clock Time1

Time2 Time3 … Time72

Clock1

Clock2

Clockn

C: searchearliest clock disaster time latest clock≦ ≦Suppose

Clock Time1 Time3 … Time72

Clock1

Clock2

Clockn

Suppose

min

min

.

.

.

max

Time span

- +12:00(if minus)

Page 17: ACM ICPC 2008  Aizu

C: time span table

Clock Time1 Time2 Time3 … Time72

Clock1 Span1,1 Span1,2 Span1,3 Span1,72

Clock2 Span2,1 Span2,2 Span2,3 Span2,72

Clockn Spann,72

earliest clock disaster time latest clock≦ ≦Time span

Minimum value of time span table indicates the answer.

Select Minimum

Shortest

Page 18: ACM ICPC 2008  Aizu

Problem D: Digits on the floor

• Recognize numbers with line segments.

Correct team 9Submit 20

Page 19: ACM ICPC 2008  Aizu

D: How to recognize

Figure

[1] 4 1 5 4 3 5 5 3 5 4[2] 4 2 6 6 5 6 6 4 6 5[3] 0 0 0 1 1 0 1 0 2 1

•[1] Number of lines•[2] Number of points•[3] Number of points on mid-Line

Page 20: ACM ICPC 2008  Aizu

D: How to distinguish 2 and 5

ab

Cross product of vector a and b

b

a

a×b < 0 a×b > 0

Page 21: ACM ICPC 2008  Aizu

D: Judge Data

Page 22: ACM ICPC 2008  Aizu

D: Judge Data

Page 23: ACM ICPC 2008  Aizu

D: Judge Data

Page 24: ACM ICPC 2008  Aizu

D: Judge Data

Page 25: ACM ICPC 2008  Aizu

D: Judge Data

Page 26: ACM ICPC 2008  Aizu

D: Judge Data

Page 27: ACM ICPC 2008  Aizu

E: Spherical Mirrors

• Ray tracing• Easy problem in the geometry domain• Answer the last mirrored point

Correct team 10Submit 12

Page 28: ACM ICPC 2008  Aizu

E: reflection

Page 29: ACM ICPC 2008  Aizu

E: reflection

cosθ

a

n

b

,1||,1||,1|| nba

nba cos2

annab )(2

Page 30: ACM ICPC 2008  Aizu

E: Intersection of Line and Sphere

ptsl Line l:

Sphere u: 2)()( rcucu

Intersection:2)()( rcsptcspt

0)()()(2 22 rcscscsptppt

This quadratic equation for t can be solved easily.

Page 31: ACM ICPC 2008  Aizu

E: select appropriate t

Minimal Positive t means the

reflection point.

×

×Minus

Greater

Page 32: ACM ICPC 2008  Aizu

Problem F: Traveling Cube

• Colored cube rolls on square tiles.• On colored tiles, the top face of cube should

be colored the same.• Cube must visit the colored tile in the

specified order.

Correct team 14Submit 18

Page 33: ACM ICPC 2008  Aizu

F: Cube on a Square Tessellation

1#23

5 4

6

Page 34: ACM ICPC 2008  Aizu

F: Search Space

• State of dice: top color 6, north color 4• Size of tiles: w*d• Number of targets: 6

Node of the graph: 6 * 4 * w * d * 6

Search the graph with Dijkstra

Page 35: ACM ICPC 2008  Aizu

G: Search of Concatenated String

• Search concatenation of all patterns.

Correct team 9Submit 55

aabccc

aabccczbaacccbaazaabbcccaa

Concatenation of all patternsaabcccaacccbbaacccbcccaacccaabcccbaa

Page 36: ACM ICPC 2008  Aizu

G: Wrong Answer (naive algorithm)

aabccczbaacccbaazaabbcccaa

aacccb

baaccc

bcccaa

cccaab

cccbaa

aabcccaacccb

baacccbcccaa

cccbaa

text

aabccc

Concatenatedpattern

Page 37: ACM ICPC 2008  Aizu

G: Wrong Answer

Complexity: n! × Text length

12! × 5000 = 2395008000000

Too Large to Solveaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa…atext

patterns a, a, a, a, a, a, a, a, a, a, a, b

Example of judge data:

Page 38: ACM ICPC 2008  Aizu

G: Acceptable Algorithm

Text

P1

P2

P3

P1,P3

P2,P3

P3

P1

P2

For each point of target string, remember the matched pattern sequence.

Page 39: ACM ICPC 2008  Aizu

G: To express matched patterns For n patterns, n bits are needed to express which patterns are matched.

000000000000 000000000001 ・・・ 111111111111

4096212 patternsTo express these bits pattern simultaneously, 4096 bits needed.

1001000000000000000000000……………………………………………………………………………0

P1 P2 P12

O(2n×Text length) of memory needed.

Page 40: ACM ICPC 2008  Aizu

H: Top Spinning

• Find the center of a top to make it spin well.• Determine whether the center of a top is on

the part of the cardboard cut out.

Correct team 0Submit 1

Page 41: ACM ICPC 2008  Aizu

H. Top Spinning

Page 42: ACM ICPC 2008  Aizu

Approximation of a Cicular Segment

by a Series of Line Segments As the accuracy requirement is not so severe,

it might be a good idea to approximate circular segments by a series of line segments

Page 43: ACM ICPC 2008  Aizu

Computing the BarycenterTriangulation

The area can be partitioned into triangles.The center of mass can be computed based on

areas and mass centers of these triangles.

Page 44: ACM ICPC 2008  Aizu

Computing the Barycenter Positive and Negative Integration Another possible way is to intepret the pa thas a graph and compute the integral of the graph.

When a segment goes leftwords, the areacan be considered negative.

Page 45: ACM ICPC 2008  Aizu

Telling Whether the Barycenter isInside the Area or Not

Summing up angles ofthe barycenter andtwo ends of segments is

2π iff it is inside.

But approximating anarc with a single linesegment may lead toa wrong decision!

Page 46: ACM ICPC 2008  Aizu

Telling Whether the Barycenter isInside the Area or NotWhether the number

ofcrosses with a raystarting from thebarycenter is even/odd

can tell outside/inside.

Here too, approximating

an arc with a line seg. is

dangerous!

Page 47: ACM ICPC 2008  Aizu

Telling Whether the Barycenter isInside the Area or Not

Direction of the path segment closest to thebarycenter can tell whether or not it isinside the area.

Page 48: ACM ICPC 2008  Aizu

Judge Data

Page 49: ACM ICPC 2008  Aizu

Judge Data

Page 50: ACM ICPC 2008  Aizu

Judge Data

Page 51: ACM ICPC 2008  Aizu

I: Common Polynomial

a ÷ b … c

Correct team 2Submit 2

b ÷ c … d

e ÷ f … 0

dividend divisor remainder

GCM

To calculate GCM, the previous divisor be the dividend, the previous remainder be the divisor. When remainder is 0, then the divisor is GCM.

Page 52: ACM ICPC 2008  Aizu

I: Common Polynomialx2 +10x+25x2 +6x+5

x2 +10x+25…[1]

…[2]

[1]-[2]

x2 +6x+5-4x+20 …[3]

[2]-[3]×x

x+5

x2 +6x+5- x2 +5x

x+5 …[4]

x+5[3]-[4]x+5-

0Common Polynomial

Subtract less degree polynomial from greater degree polynomial after making highest degree’s coefficients to the same.

Page 53: ACM ICPC 2008  Aizu

J: ZigzagCorrect team 0Submit 00

Generate all the lines which pass through two or more points.

Find all the intersections of lines.

P1 P2

I1

I2

Page 54: ACM ICPC 2008  Aizu

J: Zigzag

Generate all the line segments between each pair of (Pi,Pj),(Pi,Ij),(Ii,Ij) which pass at least two points.

For each points Pi, suppose it as a start point, and

search with Dijkstra.

P1 P2 I1 I2×