Giter Site home page Giter Site logo

Comments (6)

SamZhangQingChuan avatar SamZhangQingChuan commented on July 17, 2024 1

@SamZhangQingChuan how does your solution to O work? :)

I don't remember clearly. Looks like work out all the reachable states first and then do gaussian elimination.

from nzpc-2018.

rversteegen avatar rversteegen commented on July 17, 2024

Hi, thanks, I'll have a closer look at that.
"tried to go backwards"? What's TLE? (Edit: oh, time limit exceeded)

The trick for K is to decompose vertical and horizontal folds, handling them separately and then multiplying. For example if at a certain position the foil has been folded over 5 times when only folds along a horizontal axis are considered, and 3 times when only vertical folds are considered, that's a thickness of 15.
My solution for K stores the thickness of the foil as a list of thickness-length segments, like 5cm of thickness 2, 2cm of thickness 1. That's stored as [[2,5],[1,2]] in the R and C variables. Processing a fold then just requires splitting this list of segments in half (possibly splitting one segment) and combining the halves. Simple in theory, but easy to make off-by-one mistakes.

from nzpc-2018.

rversteegen avatar rversteegen commented on July 17, 2024

Also, in fold() in K.py, R1 and R2 are the two halves of the segment list, and when I iterate past the end of R1 or R2 I treat it as a virtual segment of length 1e9 thickness 0.

from nzpc-2018.

SamZhangQingChuan avatar SamZhangQingChuan commented on July 17, 2024

Thank you for the explanation. Do you know what the time complexity is? I feel like it is O(2^n) but this bound might be too loose.

from nzpc-2018.

rversteegen avatar rversteegen commented on July 17, 2024

Running time for a single fold operation is linear in the number of segments (as I described above). Each fold can increase the number of segments by at most one (and can reduce it). So overall the worst case number of segments is number of folds + 1 and the worst case running time is O(V^2 + H^2) in number of horizontal and vertical folds. And there are only at most 20 folds!

from nzpc-2018.

robert-king avatar robert-king commented on July 17, 2024

@SamZhangQingChuan how does your solution to O work? :)

from nzpc-2018.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.