Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

問題: Saitama Venice University #22

Merged
merged 8 commits into from
Aug 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions saitama-venice-university/PROBLEM
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# -*- coding: utf-8; mode: python -*-

pid='a'

problem(
time_limit=2.0,
id=pid,
title= "Saitama Venice University",
)
95 changes: 95 additions & 0 deletions saitama-venice-university/README.md
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$A_{i,j}$がすべて0の時の答えは0になると思うのですが, 長さ0の長靴って何?になります。
$A_{i,j}>=1$にするか, 長靴の長さが非負である(つまり0かもしれない)ことを明記するか, 正の整数であることを明記して全部0の時だけ場合分けを求めるかした方が良いと思います.

Copy link
Member Author

@a01sa01to a01sa01to Aug 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

7ae7eef サンプル 2 を全部 0 としてみました、こんな感じでどうでしょうか?

Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Saitama Venice University

実行時間制限:2 sec

## 問題文

埼玉大学の敷地は、 $H \times W$ マスで表現されます。
ある日、大雨により敷地に雨が溜まってしまいました。
マス $(i, j)$ には、 $A_{i, j}$ cm の雨が溜まっています。 ($1 \le i \le H, 1 \le j \le W$)

Asa さんはそんな状況を知り、濡れないよう長靴を履いてくることにしました。
長さ $L$ の長靴を履いていると、 $L$ cm 以下の雨が溜まっているマスに入ることができます。

すべてのマスに立ち入ることができるように、Asa さんが履くべき長靴の最小の長さを求めてください。

## 制約

- $1 \le H, W \le 1000$
- $0 \le A_{i, j} \le 10^9$
- 入力は全て整数である。

## 部分点

この問題に部分点は設定されていません。

## 入力

入力は以下の形式で標準入力から与えられる。

$H$ $W$ <br>
$A_{1, 1}$ $A_{1, 2}$ ... $A_{1, W}$ <br>
$A_{2, 1}$ $A_{2, 2}$ ... $A_{2, W}$ <br>
... <br>
$A_{H, 1}$ $A_{H, 2}$ ... $A_{H, W}$ <br>

## 出力

Asa さんが履くべき長靴の最小の長さを 1 行で出力せよ。

## サンプル

### 1

```txt
2 2
1 2
3 1
```

```txt
3
```

Asa さんは長さ 3 の長靴を履いていれば、すべてのマスに立ち入ることができます。
長さ 2 以下の長靴では立ち入ることができないマスがあるため、長さ 3 が答えとなります。

### 2

```txt
4 4
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
```

```txt
0
```

雨が溜まっていないこともあります。
このとき、求める長靴の長さは 0 となります。

### 3

```txt
3 2
46513 43287
0 213
51384 1000000000
```

```txt
1000000000
```

Asa さんと長靴は巨大です。

## 解法

- `sol-cpp-ac` : C++ AC
- `sol-cpy-ac` : CPython AC
- `sol-pypy-ac` : PyPy AC

$A_{i, j}$ の値の max を出力するだけ。
3 changes: 3 additions & 0 deletions saitama-venice-university/sol-cpp-ac/SOLUTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# -*- coding: utf-8; mode: python -*-
cxx_solution(src='main.cc', flags=["-std=c++2a", "-O2"])
expected_score(100)
15 changes: 15 additions & 0 deletions saitama-venice-university/sol-cpp-ac/main.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); ++i)

int main() {
int h, w;
cin >> h >> w;
vector a(h, vector<int>(w));
rep(i, h) rep(j, w) cin >> a[i][j];
int ans = 0;
rep(i, h) rep(j, w) ans = max(ans, a[i][j]);
cout << ans << endl;
return 0;
}
3 changes: 3 additions & 0 deletions saitama-venice-university/sol-cpy-ac/SOLUTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# -*- coding: utf-8; mode: python -*-
script_solution(src='main.py')
expected_score(100)
5 changes: 5 additions & 0 deletions saitama-venice-university/sol-cpy-ac/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/python3

h, w = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]
print(max([max(x) for x in a]))
3 changes: 3 additions & 0 deletions saitama-venice-university/sol-pypy-ac/SOLUTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# -*- coding: utf-8; mode: python -*-
script_solution(src='main.py')
expected_score(100)
5 changes: 5 additions & 0 deletions saitama-venice-university/sol-pypy-ac/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env pypy

h, w = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]
print(max([max(x) for x in a]))
3 changes: 3 additions & 0 deletions saitama-venice-university/tests/00_sample00_all.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
2 2
1 2
3 1
5 changes: 5 additions & 0 deletions saitama-venice-university/tests/00_sample01_all.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
4 4
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
4 changes: 4 additions & 0 deletions saitama-venice-university/tests/00_sample02_all.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
3 2
46513 43287
0 213
51384 1000000000
560 changes: 560 additions & 0 deletions saitama-venice-university/tests/01_random00_all.in

Large diffs are not rendered by default.

728 changes: 728 additions & 0 deletions saitama-venice-university/tests/01_random01_all.in

Large diffs are not rendered by default.

793 changes: 793 additions & 0 deletions saitama-venice-university/tests/01_random02_all.in

Large diffs are not rendered by default.

257 changes: 257 additions & 0 deletions saitama-venice-university/tests/01_random03_all.in

Large diffs are not rendered by default.

617 changes: 617 additions & 0 deletions saitama-venice-university/tests/01_random04_all.in

Large diffs are not rendered by default.

279 changes: 279 additions & 0 deletions saitama-venice-university/tests/02_hand00_all.in

Large diffs are not rendered by default.

639 changes: 639 additions & 0 deletions saitama-venice-university/tests/02_hand01_all.in

Large diffs are not rendered by default.

1,001 changes: 1,001 additions & 0 deletions saitama-venice-university/tests/03_max00_all.in

Large diffs are not rendered by default.

1,001 changes: 1,001 additions & 0 deletions saitama-venice-university/tests/03_max01_all.in

Large diffs are not rendered by default.

1,001 changes: 1,001 additions & 0 deletions saitama-venice-university/tests/03_max02_all.in

Large diffs are not rendered by default.

1,001 changes: 1,001 additions & 0 deletions saitama-venice-university/tests/03_max03_all.in

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions saitama-venice-university/tests/03_min00_all.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1 1
0
2 changes: 2 additions & 0 deletions saitama-venice-university/tests/03_min01_all.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1 1
1000000000
2 changes: 2 additions & 0 deletions saitama-venice-university/tests/03_min02_all.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1 1
526838792
9 changes: 9 additions & 0 deletions saitama-venice-university/tests/TESTSET
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# -*- coding: utf-8; mode: python -*-
cxx_validator(src="validator.cc", dependency=["testlib.h"], flags=["-std=c++2a", "-O2"])
cxx_judge(
src="judge.cc",
dependency=["testlib.h"],
variant=testlib_judge_runner,
flags=["-std=c++2a", "-O2"],
)
subtask_testset(name="All", score=100, input_patterns=["*_all.in"])
32 changes: 32 additions & 0 deletions saitama-venice-university/tests/gen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
filenames=(
"01_random00_all.in"
"01_random01_all.in"
"01_random02_all.in"
"01_random03_all.in"
"01_random04_all.in"
"02_hand00_all.in"
"02_hand01_all.in"
"03_min00_all.in"
"03_min01_all.in"
"03_min02_all.in"
"03_max00_all.in"
"03_max01_all.in"
"03_max02_all.in"
"03_max03_all.in"
)

if [ ! -f gen.out ]; then
echo "Compiling generator..."
g++ -std=c++2a -O2 -Wall -Wextra -I../../_common -o gen.out generator.cc
if [ $? -ne 0 ]; then
echo "Compilation failed."
exit 1
fi
fi

echo "Generating ${#filenames[@]} test cases..."
for filename in "${filenames[@]}"; do
echo "Generating $filename..."
./gen.out $filename > $filename
done
echo "Done."
53 changes: 53 additions & 0 deletions saitama-venice-university/tests/generator.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#include "testlib.h"

#include <vector>
using namespace std;

// ファイル名に含まれるかどうか
#define namecontains(t) (filename.find(t) != string::npos)

int main(int argc, char* argv[]) {
registerGen(argc, argv, 1);
constexpr int MaxA = 1'000'000'000; // 1e9
const string filename = argv[1];

int h = -1, w = -1;
vector<vector<int>> a;

if (namecontains("all")) {
if (namecontains("max")) {
h = 1'000, w = 1'000;
}
else if (namecontains("min")) {
h = 1, w = 1;
}
else {
h = rnd.next(1, 1'000);
w = rnd.next(1, 1'000);
}
a.assign(h, vector<int>(w));
}
else {
cerr << "Invalid filename: " << filename << endl;
return 1;
}

println(h, w);

for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
if (namecontains("hand00") || namecontains("min00") || namecontains("max00")) {
a[i][j] = 0;
}
else if (namecontains("hand01") || namecontains("min01") || namecontains("max01")) {
a[i][j] = MaxA;
}
else {
a[i][j] = rnd.next(0, MaxA);
}
}
}

for (int i = 0; i < h; ++i) println(a[i]);
return 0;
}
37 changes: 37 additions & 0 deletions saitama-venice-university/tests/judge.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// https://github.com/MikeMirzayanov/testlib/blob/master/checkers/wcmp.cpp

#include "testlib.h"

using namespace std;

int main(int argc, char *argv[]) {
setName("compare sequences of tokens");
registerTestlibCmd(argc, argv);

int n = 0;
string j, p;

while (!ans.seekEof() && !ouf.seekEof()) {
n++;

ans.readWordTo(j);
ouf.readWordTo(p);

if (j != p)
quitf(_wa, "%d%s words differ - expected: '%s', found: '%s'", n, englishEnding(n).c_str(),
compress(j).c_str(), compress(p).c_str());
}

if (ans.seekEof() && ouf.seekEof()) {
if (n == 1)
quitf(_ok, "\"%s\"", compress(j).c_str());
else
quitf(_ok, "%d tokens", n);
}
else {
if (ans.seekEof())
quitf(_wa, "Participant output contains extra tokens");
else
quitf(_wa, "Unexpected EOF in the participants output");
}
}
17 changes: 17 additions & 0 deletions saitama-venice-university/tests/validator.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include "testlib.h"

int main(int argc, char* argv[]) {
registerValidation(argc, argv);
int h = inf.readInt(1, 1'000, "h"); // 1 <= h <= 1000
inf.readSpace(); // 空白
int w = inf.readInt(1, 1'000, "w"); // 1 <= w <= 1000
inf.readEoln(); // 改行
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
inf.readInt(0, 1'000'000'000, "a[i][j]"); // 0 <= a[i][j] <= 1e9
if (j < w - 1) inf.readSpace(); // 空白
}
inf.readEoln(); // 改行
}
inf.readEof(); // EOF
}