Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Avoid using #include <bits/stdc++.h> #174

Merged
merged 11 commits into from
Aug 7, 2021
20 changes: 20 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,26 @@ Please check also the [gallery](https://kmyk.github.io/Jikka/gallery).
- :heavy_check_mark: AC `dp_z-kubaru.py`
- The Kubaru DP version of `dp_z-morau.py`.
- submission at v5.1.0.0: <https://atcoder.jp/contests/dp/submissions/24701829>
- :heavy_check_mark: AC `abc203_b.py`
- AtCoder Beginner Contest 203 [B - AtCoder Condominium](https://atcoder.jp/contests/abc203/tasks/abc203_b)
- AC with a naive solution using `sum(List[int])` / 愚直解が AC `sum(List[int])`を使用
- submission at d2be3858a1ec3b65a8cdb6228e81c85dd976a5bc: <https://atcoder.jp/contests/abc203/submissions/24820582>
- :heavy_check_mark: AC `abc204_b.py`
- AtCoder Beginner Contest 204 [B - Nuts](https://atcoder.jp/contests/abc204/tasks/abc204_b)
- AC with a naive solution / 愚直解が AC
- submission at d2be3858a1ec3b65a8cdb6228e81c85dd976a5bc: <https://atcoder.jp/contests/abc204/submissions/24820209>
- :heavy_check_mark: AC `abc206_b.py`
- AtCoder Beginner Contest 206 [B - Savings](https://atcoder.jp/contests/abc206/tasks/abc206_b)
- AC with a naive solution / 愚直解が AC
- submission at 8d1bbacd3f40a60ae8e2447c2a17a8956c7b0218: <https://atcoder.jp/contests/abc206/submissions/24817830>
- :heavy_check_mark: AC `abc207_b.py`
- AtCoder Beginner Contest 207 [B - Hydrate](https://atcoder.jp/contests/abc207/tasks/abc207_b)
- AC with a naive solution using jikka::floordiv / 愚直解が AC jikka::floordiv を使う
- submission at 8d1bbacd3f40a60ae8e2447c2a17a8956c7b0218: <https://atcoder.jp/contests/abc207/submissions/24817953>
- :heavy_check_mark: AC `abc208_b.py`
- AtCoder Beginner Contest 208 [B - Factorial Yen Coin](https://atcoder.jp/contests/abc208/tasks/abc208_b)
- AC with a naive solution using jikka::floordiv, reverse / 愚直解が AC jikka::floordiv, reverse を使う簡単な問題
- submission at 8d1bbacd3f40a60ae8e2447c2a17a8956c7b0218: <https://atcoder.jp/contests/abc208/submissions/24817975>
- :hourglass: TLE `abc134_c.py`
- AtCoder Beginner Contest 134 [C - Exception Handling](https://atcoder.jp/contests/abc134/tasks/abc134_c)
- Cumulative sums from both sides / 両側からの累積和
Expand Down
2 changes: 1 addition & 1 deletion examples/wip/abc203_b.py → examples/abc203_b.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# https://atcoder.jp/contests/abc203/tasks/abc203_b

from typing import *
# from typing import *

def solve(n: int, k: int) -> int:
a = []
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/wip/abc206_b.py → examples/abc206_b.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# https://atcoder.jp/contests/abc206/tasks/abc206_b

from typing import *
# from typing import *

def solve(n: int) -> int:
c = 0
Expand Down
2 changes: 1 addition & 1 deletion examples/wip/abc207_b.py → examples/abc207_b.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# https://atcoder.jp/contests/abc207/tasks/abc207_b

from typing import *
# from typing import *

def solve(a: int, b: int, c: int, d: int) -> int:
ans = -1
Expand Down
2 changes: 1 addition & 1 deletion examples/wip/abc208_b.py → examples/abc208_b.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# https://atcoder.jp/contests/abc208/tasks/abc208_b

from typing import *
# from typing import *

def solve(p: int) -> int:
e = 1
Expand Down
15 changes: 15 additions & 0 deletions examples/data/abc203_b.large.generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env python3
# usage: $ oj generate-input 'python3 generate.py'
# usage: $ oj generate-input --hack-actual=./a.out --hack-expected=./naive 'python3 generate.py'
import random


# generated by oj-template v4.8.1 (https://github.com/online-judge-tools/template-generator)
def main():
N = random.randint(1, 9)
K = random.randint(1, 9)
print(N, K)


if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions examples/data/abc203_b.sample-1.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1 2
1 change: 1 addition & 0 deletions examples/data/abc203_b.sample-1.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
203
1 change: 1 addition & 0 deletions examples/data/abc203_b.sample-2.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3 3
1 change: 1 addition & 0 deletions examples/data/abc203_b.sample-2.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1818
30 changes: 30 additions & 0 deletions examples/data/abc203_b.solver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <cstdint>
#include <iostream>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++(i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++(i))
#define REP_R(i, n) for (int i = (int)(n)-1; (i) >= 0; --(i))
#define REP3R(i, m, n) for (int i = (int)(n)-1; (i) >= (int)(m); --(i))
#define ALL(x) ::std::begin(x), ::std::end(x)
using namespace std;

int64_t solve(int64_t N, int64_t K) {
uint64_t ans = 0;
for (int i = 1; i <= N; ++i) {
for (int j = 1; j <= K; ++j) {
ans += 100 * i + j;
}
}
return ans;
}

// generated by oj-template v4.8.1
// (https://github.com/online-judge-tools/template-generator)
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int64_t N, K;
std::cin >> N >> K;
auto ans = solve(N, K);
std::cout << ans << '\n';
return 0;
}
18 changes: 18 additions & 0 deletions examples/data/abc204_b.large.generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env python3
# usage: $ oj generate-input 'python3 generate.py'
# usage: $ oj generate-input --hack-actual=./a.out --hack-expected=./naive 'python3 generate.py'
import random


# generated by oj-template v4.8.1 (https://github.com/online-judge-tools/template-generator)
def main():
N = random.randint(1, 1000)
A = [None for _ in range(N)]
for i in range(N):
A[i] = random.randint(1, 1000)
print(N)
print(*[A[i] for i in range(N)])


if __name__ == "__main__":
main()
2 changes: 2 additions & 0 deletions examples/data/abc204_b.sample-1.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
3
6 17 28
1 change: 1 addition & 0 deletions examples/data/abc204_b.sample-1.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
25
2 changes: 2 additions & 0 deletions examples/data/abc204_b.sample-2.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
4
8 9 10 11
1 change: 1 addition & 0 deletions examples/data/abc204_b.sample-2.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
33 changes: 33 additions & 0 deletions examples/data/abc204_b.solver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <cstdint>
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++(i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++(i))
#define REP_R(i, n) for (int i = (int)(n)-1; (i) >= 0; --(i))
#define REP3R(i, m, n) for (int i = (int)(n)-1; (i) >= (int)(m); --(i))
#define ALL(x) ::std::begin(x), ::std::end(x)
using namespace std;

int64_t solve(int N, const std::vector<int64_t> &A) {
int64_t ans = 0;
for (const auto &e : A) {
if (e > 10) {
ans += e - 10;
}
}
return ans;
}

// generated by oj-template v4.8.1
// (https://github.com/online-judge-tools/template-generator)
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int N;
std::cin >> N;
std::vector<int64_t> A(N);
REP(i, N) { std::cin >> A[i]; }
auto ans = solve(N, A);
std::cout << ans << '\n';
return 0;
}
14 changes: 14 additions & 0 deletions examples/data/abc206_b.large.generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env python3
# usage: $ oj generate-input 'python3 generate.py'
# usage: $ oj generate-input --hack-actual=./a.out --hack-expected=./naive 'python3 generate.py'
import random


# generated by oj-template v4.8.1 (https://github.com/online-judge-tools/template-generator)
def main():
N = random.randint(1, 10**9)
print(N)


if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions examples/data/abc206_b.sample-1.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
12
1 change: 1 addition & 0 deletions examples/data/abc206_b.sample-1.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5
1 change: 1 addition & 0 deletions examples/data/abc206_b.sample-2.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
100128
1 change: 1 addition & 0 deletions examples/data/abc206_b.sample-2.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
447
32 changes: 32 additions & 0 deletions examples/data/abc206_b.solver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include <cstdint>
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++(i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++(i))
#define REP_R(i, n) for (int i = (int)(n)-1; (i) >= 0; --(i))
#define REP3R(i, m, n) for (int i = (int)(n)-1; (i) >= (int)(m); --(i))
#define ALL(x) ::std::begin(x), ::std::end(x)
using namespace std;

int64_t solve(int64_t N) {
int64_t c = 0;
for (int i = 1; i < 100000; ++i) {
c += i;
if (c >= N) {
return i;
}
}
return 0; // avoid warning
}

// generated by oj-template v4.8.1
// (https://github.com/online-judge-tools/template-generator)
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int64_t N;
std::cin >> N;
auto ans = solve(N);
std::cout << ans << '\n';
return 0;
}
17 changes: 17 additions & 0 deletions examples/data/abc207_b.large.generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env python3
# usage: $ oj generate-input 'python3 generate.py'
# usage: $ oj generate-input --hack-actual=./a.out --hack-expected=./naive 'python3 generate.py'
import random


# generated by oj-template v4.8.1 (https://github.com/online-judge-tools/template-generator)
def main():
A = random.randint(1, 10**5)
B = random.randint(1, 10**5)
C = random.randint(1, 10**5)
D = random.randint(1, 10**5)
print(A, B, C, D)


if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions examples/data/abc207_b.sample-1.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5 2 3 2
1 change: 1 addition & 0 deletions examples/data/abc207_b.sample-1.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2
1 change: 1 addition & 0 deletions examples/data/abc207_b.sample-2.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6 9 2 3
1 change: 1 addition & 0 deletions examples/data/abc207_b.sample-2.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-1
28 changes: 28 additions & 0 deletions examples/data/abc207_b.solver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <cstdint>
#include <iostream>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++(i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++(i))
#define REP_R(i, n) for (int i = (int)(n)-1; (i) >= 0; --(i))
#define REP3R(i, m, n) for (int i = (int)(n)-1; (i) >= (int)(m); --(i))
#define ALL(x) ::std::begin(x), ::std::end(x)
using namespace std;

int64_t solve(int64_t A, int64_t B, int64_t C, int64_t D) {
int64_t ans = -1;
if (D * C - B > 0) {
ans = (A + D * C - B - 1) / (D * C - B);
}
return ans;
}

// generated by oj-template v4.8.1
// (https://github.com/online-judge-tools/template-generator)
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int64_t A, B, C, D;
std::cin >> A >> B >> C >> D;
auto ans = solve(A, B, C, D);
std::cout << ans << '\n';
return 0;
}
14 changes: 14 additions & 0 deletions examples/data/abc208_b.large.generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env python3
# usage: $ oj generate-input 'python3 generate.py'
# usage: $ oj generate-input --hack-actual=./a.out --hack-expected=./naive 'python3 generate.py'
import random


# generated by oj-template v4.8.1 (https://github.com/online-judge-tools/template-generator)
def main():
P = random.randint(1, 10**7)
print(P)


if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions examples/data/abc208_b.sample-1.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9
1 change: 1 addition & 0 deletions examples/data/abc208_b.sample-1.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3
1 change: 1 addition & 0 deletions examples/data/abc208_b.sample-2.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
119
1 change: 1 addition & 0 deletions examples/data/abc208_b.sample-2.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10
1 change: 1 addition & 0 deletions examples/data/abc208_b.sample-3.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10000000
1 change: 1 addition & 0 deletions examples/data/abc208_b.sample-3.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
24
38 changes: 38 additions & 0 deletions examples/data/abc208_b.solver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++(i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++(i))
#define REP_R(i, n) for (int i = (int)(n)-1; (i) >= 0; --(i))
#define REP3R(i, m, n) for (int i = (int)(n)-1; (i) >= (int)(m); --(i))
#define ALL(x) ::std::begin(x), ::std::end(x)
using namespace std;

int64_t solve(int64_t P) {
vector<int64_t> cs;
int64_t e = 1;
int64_t ans = 0;
for (int i = 1; i <= 10; ++i) {
e *= i;
cs.push_back(e);
}
reverse(cs.begin(), cs.end());
for (const auto &c : cs) {
ans += P / c;
P -= P / c * c;
}
return ans;
}

// generated by oj-template v4.8.1
// (https://github.com/online-judge-tools/template-generator)
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int64_t P;
std::cin >> P;
auto ans = solve(P);
std::cout << ans << '\n';
return 0;
}
2 changes: 1 addition & 1 deletion scripts/add_test_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def main() -> None:
plan[examples_dir / 'data' / '{}.sample-{}.out'.format(name, i + 1)] = testcase['output'].encode()
if not args.only_sample_cases:
plan[examples_dir / '{}.py'.format(name)] = subprocess.check_output(['oj-template', '-t', 'main.py', args.url])
plan[examples_dir / 'data' / '{}.solver.cpp'.format(name)] = subprocess.check_output(['oj-template', '-t', 'main.cpp', args.url])
plan[examples_dir / 'data' / '{}.solver.cpp'.format(name)] = subprocess.check_output(['oj-template', '-t', 'main.cpp', args.url]).replace(b'#include <bits/stdc++.h>\n', b'#include <cstdint>\n#include <iostream>\n#include <vector>\n') # Replace bits/stdc++.h to compile the solver on Windows.
plan[examples_dir / 'data' / '{}.large.generator.py'.format(name)] = subprocess.check_output(['oj-template', '-t', 'generate.py', args.url])

# check files
Expand Down