Giter Site home page Giter Site logo

abeaumont / competitive-programming Goto Github PK

View Code? Open in Web Editor NEW
558.0 15.0 187.0 12.53 MB

Solutions to problems from various online judges / contest sites.

License: Do What The F*ck You Want To Public License

Python 15.17% C++ 74.37% Common Lisp 2.96% OCaml 0.96% Ruby 0.34% Rust 0.35% Nim 1.72% C 0.14% Shell 0.05% Brainfuck 0.03% Dylan 1.08% Dockerfile 0.30% D 0.10% Standard ML 0.14% Haxe 0.33% MoonScript 0.10% Pony 0.24% Racket 1.01% Julia 0.33% Factor 0.27%
competitive-programming solutions kattis kattis-solutions atcoder atcoder-solutions hackerrank hackerrank-solutions hackerearth hackerearth-solutions

competitive-programming's Issues

greetingcard.cc

I have a very similar Pythonic solution to greeting card (https://open.kattis.com/problems/greetingcard) by hardcoding the only possible situations where pairs of points are exactly 2018 units apart. However, my solution failed with a "TLE" message failing on the 5/11 test case and I just couldn't figure out why.

Is your solution able to successful pass all the test cases on Kattis?

T = int(input())

lattice = []
for _ in range(T):
    x, y = map(int, input().split())
    lattice.append((x, y))

count = 0
for index in range(len(lattice)):
    cur_x = lattice[index][0] 
    cur_y = lattice[index][1]
    for jndex in range(index, len(lattice)):
        
        nex_x = lattice[jndex][0]
        nex_y = lattice[jndex][1]
        
        if ((cur_x + 2018 == nex_x and cur_y == nex_y) or
        (cur_x - 2018 == nex_x and cur_y == nex_y) or
        (cur_x == nex_x and cur_y + 2018 == nex_y) or
        (cur_x == nex_x and cur_y - 2018 == nex_y) or
        # more
        (cur_x + 1118 == nex_x and cur_y + 1680 == nex_y) or
        (cur_x + 1118 == nex_x and cur_y - 1680 == nex_y) or
        (cur_x - 1118 == nex_x and cur_y + 1680 == nex_y) or
        (cur_x - 1118 == nex_x and cur_y - 1680 == nex_y) or
        # more
        (cur_x + 1680 == nex_x and cur_y + 1118 == nex_y) or
        (cur_x + 1680 == nex_x and cur_y - 1118 == nex_y) or
        (cur_x - 1680 == nex_x and cur_y + 1118 == nex_y) or
        (cur_x - 1680 == nex_x and cur_y - 1118 == nex_y)):
            count += 1
print(count)

Help wanted

CAn you please explain why this matrix was constructed in such a way

for (int i = 0; i < 5; i++) a[i][i+1] = 1;

I know that later part will be solved by matrix exponentiation. But facing some difficulties in building the base matrix

/cses/1081.cc

I submitted the same solution you provided but it gives time limit exceeded
please recheck the solution of Common Divisors

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.