• Stars
    star
    134
  • Rank 270,967 (Top 6 %)
  • Language
    Haskell
  • License
    Apache License 2.0
  • Created over 5 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

an automated solver for problems of competitive programming

Jikka

test

Jikka is an automated solver for problems of competitive programming.

In competitive programming, there are some problems that can be solved just by repeating formula transformations or by pasting snippets of famous data structures. Jikka solves such problems automatically. Jikka takes problems as input in the form of programs of a very restricted subset of Python, optimizes the codes to reduce their computational complexity, and converts them to implementations of C++ for output. / ็ซถๆŠ€ใƒ—ใƒญใ‚ฐใƒฉใƒŸใƒณใ‚ฐใซใŠใ„ใฆใ€ŒใŸใ ๅผๅค‰ๅฝขใ‚’ใ™ใ‚‹ใ ใ‘ใง่งฃใ‘ใ‚‹ใ€ใ€ŒใŸใ ใƒ‡ใƒผใ‚ฟๆง‹้€ ใฎใƒฉใ‚คใƒ–ใƒฉใƒชใ‚’่ฒผใ‚‹ใ ใ‘ใง่งฃใ‘ใ‚‹ใ€ๅ•้กŒใฏๅฎŸใฏๅฐ‘ใชใใ‚ใ‚Šใพใ›ใ‚“ใ€‚ Jikka ใฏใใฎใ‚ˆใ†ใชๅ•้กŒใ‚’่‡ชๅ‹•ใง่งฃใ„ใฆใใ‚Œใพใ™ใ€‚ Jikka ใฏๅ•้กŒใ‚’ใจใฆใ‚‚ๅˆถ้™ใ•ใ‚ŒใŸ Python ใฎใ‚ตใƒ–ใ‚ปใƒƒใƒˆ่จ€่ชžใฎใ‚ณใƒผใƒ‰ใฎๅฝขใงๅ…ฅๅŠ›ใจใ—ใฆๅ—ใ‘ๅ–ใ‚Šใ€่จˆ็ฎ—้‡ใ‚’่ฝใจใ™ใ‚ˆใ†ใชๆœ€้ฉๅŒ–ใ‚’่กŒใ„ใ€C++ ใฎๅฎŸ่ฃ…ใซๅค‰ๆ›ใ—ใฆๅ‡บๅŠ›ใ—ใพใ™ใ€‚

Try on Web

Go https://kmyk.github.io/Jikka/playground.

Usage

$ jikka convert PYTHON_FILE

How to Install

Using prebuilt binaries (recommended)

Go Releases page and download jikka-vA.B.C.D-Linux, jikka-vA.B.C.D-maxOS or jikka-vA.B.C.D-Windows.exe.

Using Stack

Stack is required. If you are using Ubuntu, you can install Stack with $ sudo apt install haskell-stack.

$ git clone https://github.com/kmyk/Jikka.git
$ cd Jikka
$ stack install

Using Cabal

Cabal is required. This is bundled Haskell Platform. If you are using Ubuntu, you can install Stack with $ sudo apt install haskell-platform.

$ cabal update
$ cabal install Jikka

Discussions

Please feel free to use our GitHub Discussions. / GitHub Discussions ใŒใ‚ใ‚‹ใฎใงๆฐ—่ปฝใซไฝฟใฃใฆใใ ใ•ใ„ใ€‚

Documents

For users:

  • docs/language.md
    • The language specification of our restricted Python / Jikka ใงไฝฟใ‚ใ‚Œใ‚‹ๅˆถ้™ใ•ใ‚ŒใŸ Python ใฎ่จ€่ชžไป•ๆง˜
  • docs/optimization.md
    • A list of optimizations which Jikka does / Jikka ใŒ่กŒใชใฃใฆใใ‚Œใ‚‹ๆœ€้ฉๅŒ–ใฎไธ€่ฆง
  • examples/
  • CHANGELOG.md

For developpers:

Blog articles:

Examples

examples/fib.py (v5.0.5.0)

Input, O(N):

def f(n: int) -> int:
    a = 0
    b = 1
    for _ in range(n):
        c = a + b
        a = b
        b = c
    return a

def solve(n: int) -> int:
    return f(n) % 1000000007

Output, O(log N):

#include "jikka/all.hpp"
#include <algorithm>
#include <cstdint>
#include <functional>
#include <iostream>
#include <numeric>
#include <string>
#include <tuple>
#include <vector>
int64_t solve(int64_t n_317) {
  return jikka::modmatap<2, 2>(
      jikka::modmatpow<2>(jikka::make_array<std::array<int64_t, 2>>(
                              jikka::make_array<int64_t>(1, 1),
                              jikka::make_array<int64_t>(1, 0)),
                          n_317, 1000000007),
      jikka::make_array<int64_t>(1, 0), 1000000007)[1];
}
int main() {
  int64_t x318;
  std::cin >> x318;
  int64_t x319 = solve(x318);
  std::cout << x319;
  std::cout << '\n';
}

examples/static_range_sum.py (v5.0.10.0)

Input, O(N^2):

# https://judge.yosupo.jp/problem/static_range_sum

from typing import *

def solve(n: int, q: int, a: List[int], l: List[int], r: List[int]) -> List[int]:
    ans = [-1 for _ in range(q)]
    for i in range(q):
        ans[i] = sum(a[l[i]:r[i]])
    return ans

def main() -> None:
    n, q = map(int, input().split())
    a = list(map(int, input().split()))
    assert len(a) == n
    l = list(range(q))
    r = list(range(q))
    for i in range(q):
        l[i], r[i] = map(int, input().split())
    ans = solve(n, q, a, l, r)
    for i in range(q):
        print(ans[i])

if __name__ == '__main__':
    main()

Output, O(N):

#include <algorithm>
#include <cstdint>
#include <functional>
#include <iostream>
#include <numeric>
#include <string>
#include <tuple>
#include <vector>
std::vector<int64_t> solve(int64_t n_0, int64_t q_1, std::vector<int64_t> a_2,
                           std::vector<int64_t> l_3, std::vector<int64_t> r_4) {
  std::vector<int64_t> x6 = std::vector<int64_t>(a_2.size() + 1);
  x6[0] = 0;
  for (int32_t i7 = 0; i7 < int32_t(a_2.size()); ++i7) {
    x6[(i7 + 1)] = x6[i7] + a_2[i7];
  }
  std::vector<int64_t> x5 = x6;
  std::vector<int64_t> x10 = std::vector<int64_t>(q_1);
  for (int32_t i11 = 0; i11 < int32_t(q_1); ++i11) {
    x10[i11] = -x5[l_3[i11]] + x5[r_4[i11]];
  }
  return x10;
}
int main() {
  int64_t n_13 = -1;
  int64_t q_14 = -1;
  std::cin >> n_13;
  std::vector<int64_t> a_15 = std::vector<int64_t>(n_13, -1);
  std::cin >> q_14;
  std::vector<int64_t> l_16 = std::vector<int64_t>(q_14, -1);
  std::vector<int64_t> r_17 = std::vector<int64_t>(q_14, -1);
  for (int32_t i18 = 0; i18 < n_13; ++i18) {
    std::cin >> a_15[i18];
  }
  for (int32_t i_19 = 0; i_19 < q_14; ++i_19) {
    std::cin >> l_16[i_19];
    std::cin >> r_17[i_19];
  }
  for (int32_t i_20 = 0; i_20 < q_14; ++i_20) {
  }
  auto ans_21 = solve(n_13, q_14, a_15, l_16, r_17);
  for (int32_t i_22 = 0; i_22 < q_14; ++i_22) {
  }
  for (int32_t i_23 = 0; i_23 < q_14; ++i_23) {
    std::cout << ans_21[i_23] << ' ';
    std::cout << '\n' << ' ';
  }
}

License

Appache License 2.0

More Repositories

1

mersenne-twister-predictor

Predict MT19937 PRNG, from preceding 624 generated numbers. There is a specialization for the "random" of Python standard library.
Python
163
star
2

competitive-programming-library

kimiyuki's library for competitive programming with C++
C++
65
star
3

libproofofwork

Simple hash-mining c library and its python binding.
C
65
star
4

zip-crc-cracker

Python
49
star
5

google-home-say

Get Google Home to say something
JavaScript
9
star
6

longcontest-visualizer-framework

TypeScript
8
star
7

marathon-kit

Python
7
star
8

atcoder-heuristic-contest-001

C++
6
star
9

forth-to-brainfuck

translator from a subset of forth to brainfuck
Forth
5
star
10

topcoder-marathon-match-100-same-color-pairs

https://community.topcoder.com/longcontest/?module=ViewProblemStatement&rd=17143&pm=14889
C++
5
star
11

procon26

ๅ…จๅ›ฝ้ซ˜็ญ‰ๅฐ‚้–€ๅญฆๆ กใƒ—ใƒญใ‚ฐใƒฉใƒŸใƒณใ‚ฐใ‚ณใƒณใƒ†ใ‚นใƒˆ
C++
5
star
12

atcoder-heuristic-contest-002

C++
4
star
13

AtCoderProblemsStatic

an API-server compatible with kenkoooo's AtCoderProblems
Python
4
star
14

codevs-for-student-2016

https://student.codevs.jp/
C++
2
star
15

tenka1-2021-spring

C++
2
star
16

brainfuck-self-interpreter

Brainfuck
2
star
17

markov-algorithm-interpreter

Python
2
star
18

atcoder-dos2unix-userscript

TypeScript
2
star
19

topcoder-marathon-match-rating-predictor

TypeScript
1
star
20

elementary-cellular-automaton-viewer

TypeScript
1
star
21

hill-cipher-implementation

Python
1
star
22

conway-script

an esoteric programming language based on the Conway's Game of Life
C++
1
star
23

topcoder-marathon-match-tco-2018-r1-roads-and-junctions

https://community.topcoder.com/longcontest/?module=ViewProblemStatement&compid=63555&rd=17153
C++
1
star
24

malbolge-interpreter

a simple interpreter for malbolge
Python
1
star
25

yandex-optimization-2018-round-1

TypeScript
1
star
26

brainfuck-debugger

Python
1
star
27

isucon8-final

Python
1
star
28

isucon-2017-qual

Python
1
star
29

min-caml-fsharp-whitespace

F#
1
star
30

bckw-interpreter

An interpreter of BCKW combinators.
Haskell
1
star
31

cp-unspoiler

TypeScript
1
star
32

lisp-to-unlambda

a translator from Lisp to Unlambda, based on the translator to Lazy K written by Ben Rudiak-Gould
Scheme
1
star
33

codingame-hypersonic

https://www.codingame.com/contests/hypersonic
C++
1
star
34

conways-game-of-life-viewer

TypeScript
1
star
35

atcoder-shojin-moving-average

TypeScript
1
star
36

whitespace-translater

translate the whitespace-language and an assembly-language, on browser
JavaScript
1
star
37

and-not-regex-engine

a regex engine with AND operator and NOT operator
Rust
1
star
38

shoujin-slack-notifier

Python
1
star
39

self-executable-piet-generator

generates something like self-extracting archive for Piet
Perl
1
star
40

topcoder-marathon-match-repository-template

Makefile
1
star
41

liquid-types-example

F#
1
star
42

topcoder-java-arena-docker

C++
1
star
43

topcoder-marathon-match-tco-2018-poland-map-recoloring

https://community.topcoder.com/tc?module=MatchDetails&rd=17149
Java
1
star