Qualification round는 24시간 내에 1문제만 풀면 되기 때문에 그리 어려운 편은 아니지만, 어제는 어버이날이고 아점부터 약속이 3건이나 있기도 하고, 다음 라운드에서도 잘 해내려면 속도가 좀 붙어야 하기 때문에 일단 2시간 30분 내에 다 풀기로 작정하고 8시에 일어나자마자 ㄱㄱ!
영어권이 아니라는 비애를 몸소 체험하며, 문제이해가 역시 가장 어렵다는 것을 또다시 느꼈습니다. 문제 풀이 시간의 반 이상이 문제를 이해하는게 걸린것 같네요. 하여간, 이번 round에서 가장 아쉬웠던 건 large set을 별 생각없이 제출해서 기회를 박탈당한게 제일 컸습니다. 문제가 쉬워서 거의 동일한 알고리즘으로 해도 되었는데, 예외처리를 안해서 fail난 것도 있고 안습이었네요.
어제 짬짬히 구글코드잼 2009 에 참가해서 문제를 풀었는데, 2문제 밖에 못 풀었네요. 머리가 엄청 굳었나 봅니다. 늦게 풀기 시작한데다가 중간에 병원 갔다오고 잡무를 처리했는데도, 시간 카운트를 다 하네요 ㅎㅎ
33점만 넘으면 Qualification Round는 통과하니 별 문제 없겠지만, 이 다음 round 부터 통과하려면 2시간 내에 풀 수 있는 문제와 없는 문제를 후딱 선별해서 푸는 능력이 필요할 듯 합니다.
누구나 다 그렇겠지만, 코딩보다는 문제해석과 적당한 알고리즘을 선택하는게 시간이 걸리네요. 특히 전 문제해석이 너무 오래 걸리는 것 같아요. 이번에 1번과 3번 문제를 풀었는데, 1번은 금새 풀었지만 3번 문제를 특히나 아주 살짝 잘못 이해해서 왜 오답이 나오는지 모르고 오답 제출을 8번이나 하는 추태를 보였답니다 ㅠㅜ; 이 다음 목표는 round 1 통과인데, 과연 잘 되려나 모르겠네요 ^^;
A train line has two stations on it, A and B. Trains can take trips
from A to B or from B to A multiple times during a day. When a train
arrives at B from A (or arrives at A from B), it needs a certain amount
of time before it is ready to take the return journey - this is the turnaround time. For example, if a train arrives at 12:00 and the turnaround time is 0 minutes, it can leave immediately, at 12:00.
A train timetable specifies departure and arrival time of all trips between A and B. The train company needs to know how many
trains have to start the day at A and B in order to make the timetable work:
whenever a train is supposed to leave A or B, there must actually be one there
ready to go. There are passing sections on the track, so trains don't
necessarily arrive in the same order that they leave. Trains may not travel on trips that do not appear on the schedule.
Input
The first line of input gives the number of cases, N. N test
cases follow.
Each case contains a number of lines. The first line is the
turnaround time, T, in minutes. The next line has two numbers on it,
NA and NB. NA is the number of trips from A to B,
and NB is the number of trips from B to A. Then there are
NA lines giving the details of the trips from A to B.
Each line contains two fields, giving the HH:MM departure and arrival
time for that trip. The departure time for each trip will be earlier
than the arrival time. All arrivals and departures occur on the same
day. The trips may appear in any order - they are not necessarily
sorted by time. The hour and minute values are both two digits,
zero-padded, and are on a 24-hour clock (00:00 through 23:59).
After these NA lines,
there are NB lines giving the departure and arrival times for the
trips from B to A.
Output
For each test case, output one line containing "Case #x: " followed
by the number of trains that must start at A and the number of trains that
must start at B.
C:\CodeJam\2008Qualification\TrainT imetable>c:\Python25\python.exe run.py B-small-practice.in the number of tc : 20 Case #1: 0 2 Case #2: 1 0 Case #3: 2 0 Case #4: 4 2 Case #5: 3 1 Case #6: 3 2 Case #7: 3 5 Case #8: 1 10 Case #9: 8 7 Case #10: 7 7 Case #11: 7 11 Case #12: 1 1 Case #13: 2 0 Case #14: 3 6 Case #15: 13 0 Case #16: 0 8 Case #17: 6 8 Case #18: 2 2 Case #19: 6 3 Case #20: 8 4
C:\CodeJam\2008Qualification\TrainT imetable>c:\Python25\python.exe run.py B-large-practice.in the number of tc : 100 Case #1: 0 2 Case #2: 1 0 Case #3: 3 2 Case #4: 1 1 Case #5: 4 1 Case #6: 2 2 Case #7: 3 3 Case #8: 5 6 Case #9: 2 10 Case #10: 0 44 Case #11: 10 35 Case #12: 8 29 Case #13: 84 5 Case #14: 2 11 Case #15: 21 0 Case #16: 6 10 Case #17: 14 0 Case #18: 0 11 Case #19: 6 10 Case #20: 4 2 Case #21: 4 6 Case #22: 7 5 Case #23: 50 50 Case #24: 40 35 Case #25: 27 31 Case #26: 25 26 Case #27: 16 29 Case #28: 10 32 Case #29: 14 20 Case #30: 10 26 Case #31: 5 26 Case #32: 8 26 Case #33: 8 26 Case #34: 9 27 Case #35: 9 28 Case #36: 6 33 Case #37: 7 35 Case #38: 5 35 Case #39: 4 37 Case #40: 4 38 Case #41: 6 41 Case #42: 4 42 Case #43: 12 34 Case #44: 5 42 Case #45: 9 38 Case #46: 8 39 Case #47: 6 43 Case #48: 6 42 Case #49: 5 45 Case #50: 6 46 Case #51: 4 51 Case #52: 9 55 Case #53: 11 56 Case #54: 7 54 Case #55: 10 59 Case #56: 7 62 Case #57: 9 66 Case #58: 9 65 Case #59: 8 74 Case #60: 13 74 Case #61: 8 82 Case #62: 17 78 Case #63: 50 49 Case #64: 26 25 Case #65: 21 17 Case #66: 21 10 Case #67: 17 10 Case #68: 16 9 Case #69: 16 7 Case #70: 11 11 Case #71: 12 6 Case #72: 12 9 Case #73: 10 8 Case #74: 9 9 Case #75: 11 9 Case #76: 9 7 Case #77: 8 10 Case #78: 9 8 Case #79: 10 6 Case #80: 10 5 Case #81: 9 7 Case #82: 7 6 Case #83: 2 1 Case #84: 2 1 Case #85: 2 1 Case #86: 1 2 Case #87: 2 1 Case #88: 2 1 Case #89: 3 2 Case #90: 3 2 Case #91: 1 2 Case #92: 1 2 Case #93: 2 1 Case #94: 4 1 Case #95: 3 1 Case #96: 1 2 Case #97: 4 2 Case #98: 2 2 Case #99: 2 2 Case #100: 10 9
요즘 기분이 꿀꿀해서 CodeJam 2008 Qualification Round 문제 중 하나인, 'Saving the Universe'를 풀어봤습니다.
1번 문제(Saving the Universe)는 다음과 같습니다.
Problem
The urban legend goes that if you go to the Google homepage and search
for "Google", the universe will implode. We have a secret to share...
It is true! Please don't try it, or tell anyone. All right, maybe not.
We are just kidding.
The same is not true for a universe far far away. In that universe,
if you search on any search engine for that search engine's name, the
universe does implode!
To combat this, people came up with an interesting solution. All
queries are pooled together. They are passed to a central system that
decides which query goes to which search engine. The central system
sends a series of queries to one search engine, and can switch to
another at any time. Queries must be processed in the order they're
received. The central system must never send a query to a search engine
whose name matches the query. In order to reduce costs, the number of
switches should be minimized.
Your task is to tell us how many times the central system will have
to switch between search engines, assuming that we program it
optimally.
Input
The first line of the input file contains the number of cases, N. N test cases follow.
Each case starts with the number S -- the number of search engines. The next S
lines each contain the name of a search engine. Each search engine name
is no more than one hundred characters long and contains only uppercase
letters, lowercase letters, spaces, and numbers. There will not be two
search engines with the same name.
The following line contains a number Q -- the number of incoming queries. The next Q lines will each contain a query. Each query will be the name of a search engine in the case.
Output
For each input case, you should output:
Case #X: Y
where X is the number of the test case and Y is the number of search engine switches.
Do not count the initial choice of a search engine as a switch.
C:\CodeJam\2008Qualification\Saving Universe>c:\Python25\python.exe savinguniverse.py A-small-practice.in the number of tc : 20 Case #1: 0 Case #2: 0 Case #3: 1 Case #4: 1 Case #5: 3 Case #6: 3 Case #7: 99 Case #8: 48 Case #9: 10 Case #10: 3 Case #11: 0 Case #12: 1 Case #13: 5 Case #14: 2 Case #15: 0 Case #16: 1 Case #17: 2 Case #18: 3 Case #19: 1 Case #20: 2
C:\CodeJam\2008Qualification\Saving Universe>c:\Python25\python.exe savinguniverse.py A-large-practice.in the number of tc : 20 Case #1: 0 Case #2: 0 Case #3: 1 Case #4: 1 Case #5: 3 Case #6: 3 Case #7: 999 Case #8: 498 Case #9: 12 Case #10: 1 Case #11: 4 Case #12: 1 Case #13: 6 Case #14: 0 Case #15: 1 Case #16: 11 Case #17: 1 Case #18: 3 Case #19: 3 Case #20: 2