Блог пользователя Tima

Автор Tima, история, 8 лет назад, По-английски

Code Jam Round 1A starts in under 6 hours.

Let's discuss the problems here after the contest.

GL & HF.

  • Проголосовать: нравится
  • +116
  • Проголосовать: не нравится

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +12 Проголосовать: не нравится

How to solve problem 2?

  • »
    »
    8 лет назад, скрыть # ^ |
    Rev. 2  
    Проголосовать: нравится +20 Проголосовать: не нравится

    Binary search the time T.

    To answer whether you can process B bits with R cashiers, just calculate for every cashier and take top R, if their sum is greater than or equal to B then you can process B bits in time T with R cashiers.

    • »
      »
      »
      8 лет назад, скрыть # ^ |
      Rev. 2  
      Проголосовать: нравится +3 Проголосовать: не нравится

      I have done the same thing. I don't know what's wrong with my code.

      Code
»
8 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

After the GCJ Round 1A, Square869120Contest #5 will be held at Atcoder.
Let's participate and enjoy!!!!!
Contest Page

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +19 Проголосовать: не нравится

How to test a code after the contest?

»
8 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

It feels strange to fail hidden tests of problems 1 and 2 but to pass the third's one.

»
8 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

How to solve problem 1 ? I think I have understood the logic, but I just couldn't solve the problem. Can anyone please look into my code ?

https://ideone.com/Kz1GgQ

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

What's wrong with my B??? Isn't B just binary search + greedy? I get shocked seeing this fail the large test.

My solution

»
8 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

So apparently Google Code Jam won't even show the reason for Runtime error, which is quite unfortunate.

Oh well, in my case the issue was me using a different g++ version and not specifying explicitly -std=c++11 flag.

»
8 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +5 Проголосовать: не нравится

What is a solution for C (Edgy Baking)?

  • »
    »
    8 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +10 Проголосовать: не нравится

    If we know which ones we'll cut we can calculate the range [l, r] perimeter lies within. The dp[l] = max possible r, so it's just knapsack. If p lies within some [l, dp[l]] range then answer is p, else answer is maximum dp[l] where l <= p. It's about 100 * 250 * 6 for one test.

  • »
    »
    8 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +10 Проголосовать: не нравится

    For one rectangle that is cut perimeter lies within [(a + b) * 2 + min(a, b) * 2, (a + b) * 2 + hypot(a, b) * 2]

  • »
    »
    8 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +42 Проголосовать: не нравится

    I solved problem C with DP.

    You can replace the problem with following problem:

    You are given N intervals: [Li, Ri]. You can choose any subset of intervals.
    You can choose number which included in each interval in subsets.
    The goal is to set total number you chose closer to P (not larger than P.)

    You can solve this problem with DP because Li is always an integer.
    Let dp[pos][minimum] be the maximum value of "sum of Ri in the subset" which looks from interval 1 to pos and "sum of Li in the subset" is minimum.

    The transition of DP is as follows:
    dp[pos + 1][minimum] = max(dp[pos + 1][minimum], dp[pos][minimum])
    dp[pos + 1][minimum + Lpos] = max(dp[pos + 1][minimum + Lpos], dp[pos][minimum + Rpos])

    The complexity is O(N * (H1 + H2 + ... + HN)).

    Code

  • »
    »
    8 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    Can someone help me debug C large, I copied the dp solution written elsewhere here but I get the same answers on 10000+ random inputs. I got WA on the contest on the function "solve"

    https://hastebin.com/lovudorume.py

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +11 Проголосовать: не нравится

How to see friend standings?

»
8 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +30 Проголосовать: не нравится

Problem A with a very little difference:

»
8 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

My solution received TLE. There are 100 test cases and time limit is 15 seconds so it should not happen, right?

»
8 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I wonder if somebody had similar feeling that B easy was harder than B hard. I already encountered this situation 2 years ago in 1C problem.

I was trying to check every mask of R cashiers out of C and then what? How to optimally assign B bits to given set of R cashiers?

I think that if the problem was given with smaller constraints it would be much harder/trickier to solve, as it would be much more difficult to get BS idea.

»
8 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Its really bad that we can't upsolve problems after the contest. Its really important for us as you already know. We can't even download sources of people who got full score and create our own testcases and after test our source with these testcases (not the best solution but from nothing its better). So please if anyone who got full score in any problem and wants to help, could share his/her sources ? Thank you !

»
8 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I have an interesting solution for problem C that works in O(n^3) which was inspired by IOI 2016 Molecules.

WLOG, all widths<=heights and the optimal solution requires cutting at least 3 cookies. Let's iterate over all unordered triples of cookies (A, B, C) and let A, B, and C have the greatest widths among the cookies that will be cut.

WLOG, let C have the smallest width among the triple. The length of the range of possible perimeters when A, B, and C are cut is at least 3*2*(sqrt2-1)*C.width (the smallest cut is C.width and the largest is sqrt2*C.width).

If an additional cookie is cut (remember that the widths of additional cookies <= C.width), the lower bound of the range will increase by at most 2*C.width. Because 3*2*(sqrt2-1)*C.width > 2*C.width, the new lower bound must be smaller than the previous upper bound, and no values will be skipped if we cut an additional cookie. Thus, we can just cut all cookies with widths <= C.width and the answer for a triple is min(upper bound, maximum perimeter).

AC solution without template
»
8 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

Unfortunately I could not wake up for the round and now I can't find the problemset. Anybody knows where can I see the problems?

»
8 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Can someone help me with problem 2? I thought O(60 * R * C) was good enough to pass but turned out TLE.

My solution

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится

How to submit after contest?