Skip to content

Commit

Permalink
#50 add: multiple statements by single setting file
Browse files Browse the repository at this point in the history
  • Loading branch information
tsutaj committed Aug 27, 2021
1 parent 510132e commit f114e5a
Show file tree
Hide file tree
Showing 18 changed files with 331 additions and 94 deletions.
15 changes: 9 additions & 6 deletions sample/A/problem.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
# problem id (it is used for the name of output html file)
id = "A"

# pato to statements
statements_path = [
["./statement/statement_ja.md", "ja"],
["./statement/statement_en.md", "en"],
]

# output params
params_path = "./tests/constraints.hpp"

# path to statements
[[statements]]
path = "./statement/statement_ja.md"
lang = "ja"

[[statements]]
path = "./statement/statement_en.md"
lang = "en"

# write constraints
[constraints]
MIN_AB = 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
Note that a new-line is required in the end of output.

1 change: 1 addition & 0 deletions sample/A/tests/ja/00_sample_00.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
出力の最後の改行を忘れないようご注意ください。
12 changes: 7 additions & 5 deletions sample/B/problem.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# 問題 ID (必須, 出力 html 名に使用される)
id = "B"

# 問題文が格納されている場所
# mode が local である場合、Markdown ファイルへのパスを記載する
statements_path = [
["./statement/statement.md", "ja"],
]
# 制約の出力先となるファイル名
params_path = "./tests/constraints.hpp"

# 問題文が格納されている場所
# 問題文ファイルがローカルにある場合、Markdown ファイルへのパスを記載する
[[statements]]
path = "./statement/statement.md"
lang = "ja"

# 問題制約を書く
[constraints]
MIN_N = 1
Expand Down
37 changes: 37 additions & 0 deletions sample/C/problem.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# problem id (it is used for the name of output html file)
id = "C"

# output params
params_path = "./tests/constraints.hpp"

# path to statements
[[statements]]
path = "./statement/en/statement_1.md"
lang = "en"

[[statements]]
path = "./statement/en/statement_2.md"
lang = "en"

[[statements]]
path = "./statement/ja/statement_1.md"
lang = "ja"

[[statements]]
path = "./statement/ja/statement_2.md"
lang = "ja"

# write constraints
[constraints]
MIN_A = 1
MAX_A = 1_000_000_000

MIN_N_SMALL = 1
MAX_N_SMALL = 1000
MIN_Q_SMALL = 1
MAX_Q_SMALL = 1000

MIN_N_LARGE = 1
MAX_N_LARGE = 100_000
MIN_Q_LARGE = 1
MAX_Q_LARGE = 100_000
31 changes: 31 additions & 0 deletions sample/C/statement/en/statement_1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Static Range Sum

## Note

The difference between C1 and C2 is only constraints of $N$ and $Q$.

## Problem statement

You are given a non-negative integer sequence $A = (a_0, a_1, \ldots, a_{N-1})$ with the length $N$. Process the following $Q$ queries in order:

- You are given integers $l_i$​ and $r_i$​. Print $\sum_{k=l_i}^{r_i-1}$​.

## Input

```
$N$ $Q$
$a_0$​ $a_1$​ $\ldots$ $a_{N-1}$​
$l_1$​ $r_1$​
$\vdots$
$l_Q$​ $r_Q$​
```

- All inputs are integers.
- ${@constraints.MIN_N_SMALL} \leq N \leq {@constraints.MAX_N_SMALL}$
- ${@constraints.MIN_Q_SMALL} \leq Q \leq {@constraints.MAX_Q_SMALL}$
- ${@constraints.MIN_A} \leq a_i \leq {@constraints.MAX_A}$
- $1 \leq l_i < r_i \leq N$

## Sample

{@samples.all}
31 changes: 31 additions & 0 deletions sample/C/statement/en/statement_2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Static Range Sum

## Note

The difference between C1 and C2 is only constraints of $N$ and $Q$.

## Problem statement

You are given a non-negative integer sequence $A = (a_0, a_1, \ldots, a_{N-1})$ with the length $N$. Process the following $Q$ queries in order:

- You are given integers $l_i$​ and $r_i$​. Print $\sum_{k=l_i}^{r_i-1}$​.

## Input

```
$N$ $Q$
$a_0$​ $a_1$​ $\ldots$ $a_{N-1}$​
$l_1$​ $r_1$​
$\vdots$
$l_Q$​ $r_Q$​
```

- All inputs are integers.
- ${@constraints.MIN_N_LARGE} \leq N \leq {@constraints.MAX_N_LARGE}$
- ${@constraints.MIN_Q_LARGE} \leq Q \leq {@constraints.MAX_Q_LARGE}$
- ${@constraints.MIN_A} \leq a_i \leq {@constraints.MAX_A}$
- $1 \leq l_i < r_i \leq N$

## Sample

{@samples.all}
31 changes: 31 additions & 0 deletions sample/C/statement/ja/statement_1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Static Range Sum

## 注意

問題 C1 と C2 では、$N$ と $Q$ の制約のみが異なります。

## 問題文

長さ $N$ の非負整数列 $A = (a_0, a_1, \ldots, a_{N-1})$ が与えられます。以下で説明されるクエリを順に $Q$ 回処理してください。

- 整数 $l_i$​ と $r_i$​ が与えられるので、$\sum_{k=l_i}^{r_i-1}$​ を出力する。

## 入力

```
$N$ $Q$
$a_0$​ $a_1$​ $\ldots$ $a_{N-1}$​
$l_1$​ $r_1$​
$\vdots$
$l_Q$​ $r_Q$​
```

- 入力は全て整数で与えられる
- ${@constraints.MIN_N_SMALL} \leq N \leq {@constraints.MAX_N_SMALL}$
- ${@constraints.MIN_Q_SMALL} \leq Q \leq {@constraints.MAX_Q_SMALL}$
- ${@constraints.MIN_A} \leq a_i \leq {@constraints.MAX_A}$
- $1 \leq l_i < r_i \leq N$

## 入出力例

{@samples.all}
31 changes: 31 additions & 0 deletions sample/C/statement/ja/statement_2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Static Range Sum

## 注意

問題 C1 と C2 では、$N$ と $Q$ の制約のみが異なります。

## 問題文

長さ $N$ の非負整数列 $A = (a_0, a_1, \ldots, a_{N-1})$ が与えられます。以下で説明されるクエリを順に $Q$ 回処理してください。

- 整数 $l_i$​ と $r_i$​ が与えられるので、$\sum_{k=l_i}^{r_i-1}$​ を出力する。

## 入力

```
$N$ $Q$
$a_0$​ $a_1$​ $\ldots$ $a_{N-1}$​
$l_1$​ $r_1$​
$\vdots$
$l_Q$​ $r_Q$​
```

- 入力は全て整数で与えられる
- ${@constraints.MIN_N_LARGE} \leq N \leq {@constraints.MAX_N_LARGE}$
- ${@constraints.MIN_Q_LARGE} \leq Q \leq {@constraints.MAX_Q_LARGE}$
- ${@constraints.MIN_A} \leq a_i \leq {@constraints.MAX_A}$
- $1 \leq l_i < r_i \leq N$

## 入出力例

{@samples.all}
7 changes: 7 additions & 0 deletions sample/C/tests/00_sample_00.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
5 5
1 10 100 1000 10000
2 3
0 3
2 5
3 4
0 5
5 changes: 5 additions & 0 deletions sample/C/tests/00_sample_00.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
100
111
11100
1000
11111
19 changes: 9 additions & 10 deletions sample/H/problem.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# 問題 ID (必須, 出力 html 名にも使用される)
id = "H"

# 制約の出力先となるファイル名
params_path = "./tests/constraints.hpp"

# 問題文が格納されている場所 (必須)
# mode が Docs である場合、Google Docs の URL または Document ID を記載する
# Google Docs で問題文を管理している場合、Google Docs の URL または Document ID を記載する
# (Document ID とは Docs の URL にある、ランダムのような文字列のことです)
# 以下に示す 2 種類の書き方が許容される
statements_path = [
["1MoguVNpp2SgJvF0ncPbp_8_x2_GhClMijUjF3U3g8ns", "ja"],
]
# statement_path = [
# ["https://docs.google.com/document/d/1MoguVNpp2SgJvF0ncPbp_8_x2_GhClMijUjF3U3g8ns/edit?usp=sharing", "ja"]
# ]

params_path = "./tests/constraints.hpp"
# 'path' は、以下に示す 2 種類の書き方が許容される
[[statements]]
path = "1MoguVNpp2SgJvF0ncPbp_8_x2_GhClMijUjF3U3g8ns"
# path = "https://docs.google.com/document/d/1MoguVNpp2SgJvF0ncPbp_8_x2_GhClMijUjF3U3g8ns/edit?usp=sharing"
lang = "ja"
File renamed without changes.
File renamed without changes.
14 changes: 9 additions & 5 deletions sample/I/problem.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
# 問題 ID (必須: 出力 html 名にも使用される)
id = "I"

# 問題文が格納されている場所
# mode が local である場合、Markdown ファイルへのパスを記載する
statements_path = [
["./statement/statement.md", "ja"]
]
# 制約の出力先となるファイル名
params_path = "./tests/constraints.hpp"

# 添付ファイルが格納されているフォルダ名
assets_path = "./statement/assets/"

# 問題文が格納されている場所
# 問題文ファイルがローカルにある場合、Markdown ファイルへのパスを記載する
[[statements]]
path = "./statement/statement.md"
lang = "ja"

# 問題制約を書く
[constraints]
MIN_N = 1
Expand Down
18 changes: 1 addition & 17 deletions statements_manager/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,23 +74,7 @@ def subcommand_run(working_dir: str, output: str) -> None:
logger.debug(f"run: working_dir = '{working_dir}'")
project = Project(working_dir, output) # Project

# check mode
for problem_id, config in project.problem_attr.items():
mode = config["mode"].lower() # type: str
lang = config["lang"].lower() # type: str

if mode == "docs":
logger.info(f"running in 'docs' mode (lang: {lang})")
project.set_config(config, mode="docs")
elif mode == "local":
logger.info(f"running in 'local' mode (lang: {lang})")
project.set_config(config, mode="local")
else:
logger.error(f"unknown mode: {mode}")
raise ValueError(f"unknown mode: {mode}")
project.run_problem()
logger.info("")

project.run_problems()
logger.debug("run for problem set")
project.run_problemset()
logger.debug("run command ended successfully.")
Expand Down
Loading

0 comments on commit f114e5a

Please sign in to comment.