Skip to content

Commit 11d0ec1

Browse files
committed
Merge remote-tracking branch 'origin' into tossy/json-generator
2 parents 8c2c011 + d7dbce5 commit 11d0ec1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+1106
-34
lines changed

Diff for: a*b/PROBLEM renamed to a-mul-b/PROBLEM

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: a*b/statement.md renamed to a-mul-b/statement.md

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: battle_royal/PROBLEM

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# -*- coding: utf-8; mode: python -*-
2+
3+
pid='X'
4+
5+
problem(
6+
time_limit=1.0,
7+
id=pid,
8+
title=pid + "Battle Royal",
9+
#wiki_name="Your pukiwiki page name", # for wikify plugin
10+
#assignees=['Assignees', 'for', 'this', 'problem'], # for wikify plugin
11+
#need_custom_judge=True, # for wikify plugin
12+
reference_solution='shinya',
13+
)
14+
15+
atcoder_config(
16+
task_id=None # None means a spare
17+
)

Diff for: battle_royal/cpp-ryoissy/SOLUTION

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# -*- coding: utf-8; mode: python -*-
2+
3+
## Solution
4+
#c_solution(src='main.c') # -lm -O2 as default
5+
cxx_solution(src='ryoissy-battleroyal.cpp', flags=[]) # -std=c++11 -O2 as default
6+
#java_solution(src='Main.java', encoding='UTF-8', mainclass='Main')
7+
#java_solution(src='Main.java', encoding='UTF-8', mainclass='Main',
8+
# challenge_cases=[])
9+
#java_solution(src='Main.java', encoding='UTF-8', mainclass='Main',
10+
# challenge_cases=['10_corner*.in'])
11+
#script_solution(src='main.sh') # shebang line is required
12+
#script_solution(src='main.pl') # shebang line is required
13+
#script_solution(src='main.py') # shebang line is required
14+
#script_solution(src='main.rb') # shebang line is required
15+
#js_solution(src='main.js') # javascript (nodejs)
16+
#hs_solution(src='main.hs') # haskell (stack + ghc)
17+
#cs_solution(src='main.cs') # C# (mono)
18+
19+
## Score
20+
#expected_score(100)

Diff for: battle_royal/cpp-ryoissy/ryoissy-battleroyal.cpp

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <bits/stdc++.h>
2+
#define MOD 1000000007LL
3+
using namespace std;
4+
typedef long long ll;
5+
typedef pair<int,int> P;
6+
7+
void solve(){
8+
int cnt=0;
9+
for(int i=0;i<100;i++){
10+
int a;
11+
scanf("%d",&a);
12+
cnt+=a;
13+
}
14+
printf("%d\n",100-cnt);
15+
}
16+
17+
int main(void){
18+
int t;
19+
scanf("%d",&t);
20+
for(int i=0;i<t;i++){
21+
solve();
22+
}
23+
return 0;
24+
}

Diff for: battle_royal/python-correct/SOLUTION

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# -*- coding: utf-8; mode: python -*-
2+
3+
## Solution
4+
#c_solution(src='main.c') # -lm -O2 as default
5+
#cxx_solution(src='main.cc', flags=[]) # -std=c++11 -O2 as default
6+
#java_solution(src='Main.java', encoding='UTF-8', mainclass='Main')
7+
#java_solution(src='Main.java', encoding='UTF-8', mainclass='Main', challenge_cases=[])
8+
#java_solution(src='Main.java', encoding='UTF-8', mainclass='Main', challenge_cases=['10_corner*.in'])
9+
#script_solution(src='main.sh') # shebang line is required
10+
#script_solution(src='main.pl') # shebang line is required
11+
script_solution(src='main.py') # shebang line is required
12+
#script_solution(src='main.rb') # shebang line is required
13+
#js_solution(src='main.js') # javascript (nodejs)
14+
#hs_solution(src='main.hs') # haskell (stack + ghc)
15+
#cs_solution(src='main.cs') # C# (mono)
16+
17+
## Score
18+
#expected_score(100)

Diff for: battle_royal/python-correct/main.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/local/bin/python3
2+
# -*- coding: utf-8 -*-
3+
4+
def solve():
5+
kill = list(map(int,input().split()))
6+
kill.sort()
7+
8+
n = len(kill)
9+
alive = [1]*n
10+
11+
for i in range(n):
12+
rem = kill[i]
13+
for j in range(i):
14+
if rem == 0:
15+
break
16+
17+
if alive[j]:
18+
alive[j] = 0
19+
rem -= 1
20+
21+
assert rem == 0
22+
23+
print(sum(alive))
24+
25+
def main():
26+
for _ in range(int(input())):
27+
solve()
28+
29+
if __name__ == '__main__':
30+
main()

Diff for: battle_royal/shinya/SOLUTION

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# -*- coding: utf-8; mode: python -*-
2+
3+
## Solution
4+
#c_solution(src='main.c') # -lm -O2 as default
5+
cxx_solution(src='main.cpp', flags=[]) # -std=c++11 -O2 as default
6+
#java_solution(src='Main.java', encoding='UTF-8', mainclass='Main')
7+
#java_solution(src='Main.java', encoding='UTF-8', mainclass='Main',
8+
# challenge_cases=[])
9+
#java_solution(src='Main.java', encoding='UTF-8', mainclass='Main',
10+
# challenge_cases=['10_corner*.in'])
11+
#script_solution(src='main.sh') # shebang line is required
12+
#script_solution(src='main.pl') # shebang line is required
13+
#script_solution(src='main.py') # shebang line is required
14+
#script_solution(src='main.rb') # shebang line is required
15+
#js_solution(src='main.js') # javascript (nodejs)
16+
#hs_solution(src='main.hs') # haskell (stack + ghc)
17+
#cs_solution(src='main.cs') # C# (mono)
18+
19+
## Score
20+
#expected_score(100)

Diff for: battle_royal/shinya/main.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
int main(void) {
5+
const int N = 100;
6+
int T;
7+
int K[N];
8+
9+
cin >> T;
10+
for(int t = 0; t < T; t++) {
11+
for(int i = 0; i < N; i++) {
12+
cin >> K[i];
13+
}
14+
15+
int sum = 0;
16+
for(int i = 0; i < N; i++) {
17+
sum += K[i];
18+
}
19+
cout << N - sum << endl;
20+
}
21+
22+
return 0;
23+
}

Diff for: battle_royal/statement.md

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Description
2+
3+
荒廃した孤島に100人のプレイヤーが集められました。
4+
彼らは武器と知恵を駆使して、生き残りを懸けたバトルロイヤルを始めます。
5+
6+
バトルロイヤルでは、プレイヤーは他のプレイヤーに攻撃を仕掛けて脱落させることができます。
7+
その際、あるプレイヤーが他のプレイヤーを1人脱落させるごとに、脱落させたプレイヤーの**キル数**が1ずつ増加します。
8+
脱落させられたプレイヤーのキル数は変化しません。
9+
10+
100人のプレイヤーそれぞれについて$i$番目のプレイヤーのキル数$K_i$が与えられるので、脱落せずに生き残っているプレイヤーの人数を求めてください。
11+
ただし、プレイヤーが他のプレイヤーによるキル以外によってひとりでに脱落することはないものとします。
12+
13+
# Constraints
14+
15+
- プレイヤー数は$100$である
16+
- $i$番目のプレイヤーのキル数$K_i (1 \leq i \leq 100)$は0以上の整数である
17+
- 100人のプレイヤーのキル数としてありえない入力は与えられない
18+
19+
# Input
20+
21+
1つの入力ファイルは複数のテストケースからなる。
22+
23+
入力ファイルの最初の1行目にはテストケースの個数$T$が記される$(1 \leq T \leq 100)$。
24+
25+
2行目以降には、$T$個のテストケースが記述されており、各テストケースは次の形式で表される。
26+
27+
```
28+
$K_1$ $K_2$ $\ldots$ $K_{100}$
29+
```
30+
31+
ただし、$K_i$は$i$人目$(1 \leq i \leq 100)$のプレイヤーのキル数を表す。
32+
33+
# Output
34+
35+
各テストケースに対して、脱落せずに生き残っているプレイヤーの人数を出力せよ。
36+
37+
# Sample Input
38+
39+
```
40+
4
41+
0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
42+
20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
43+
0 0 1 1 0 2 0 0 1 0 0 2 0 2 1 2 0 0 0 1 0 2 1 1 2 1 3 2 0 4 1 0 1 0 1 2 2 1 0 0 1 0 1 1 0 1 1 0 0 1 1 1 0 0 1 0 2 1 1 1 1 0 3 1 1 0 0 4 1 1 2 0 1 2 0 0 2 1 1 0 1 1 2 0 3 0 2 1 1 0 1 1 1 2 0 1 1 0 1 1
44+
1 2 1 1 0 0 1 1 1 1 0 0 1 0 1 1 0 2 1 3 0 2 0 1 2 0 1 2 3 3 0 1 2 0 2 0 1 1 0 2 2 2 0 1 1 1 1 0 0 1 1 2 1 1 0 1 3 0 1 1 0 0 0 0 2 3 0 2 1 0 2 2 0 0 1 2 0 0 1 1 1 1 0 1 0 0 3 1 1 1 0 1 1 1 1 2 1 3 0 0
45+
```
46+
47+
# Sample Output
48+
49+
```
50+
1
51+
80
52+
8
53+
3
54+
```

Diff for: battle_royal/tests/TESTSET

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# -*- coding: utf-8; mode: python -*-
2+
3+
## Input generators.
4+
#c_generator(src='generator.c')
5+
cxx_generator(src='generator.cpp', dependency=['testlib.h'])
6+
#java_generator(src='Generator.java', encoding='UTF-8', mainclass='Generator')
7+
#script_generator(src='generator.pl')
8+
9+
## Input validators.
10+
#c_validator(src='validator.c')
11+
cxx_validator(src='validator.cpp', dependency=['testlib.h'])
12+
#java_validator(src='Validator.java', encoding='UTF-8',
13+
# mainclass='tmp/validator/Validator')
14+
#script_validator(src='validator.pl')
15+
16+
## Output judges.
17+
#c_judge(src='judge.c')
18+
#cxx_judge(src='judge.cc', dependency=['testlib.h'],
19+
# variant=testlib_judge_runner)
20+
#java_judge(src='Judge.java', encoding='UTF-8', mainclass='Judge')
21+
#script_judge(src='judge.py')
22+
23+
## Reactives.
24+
#c_reactive(src='reactive.c')
25+
#cxx_reactive(src='reactive.cc', dependency=['testlib.h', 'reactive.hpp'],
26+
# variant=kupc_reactive_runner)
27+
#java_reactive(src='Reactive.java', encoding='UTF-8', mainclass='Judge')
28+
#script_reactive(src='reactive.py')
29+
30+
## Extra Testsets.
31+
# icpc type
32+
#icpc_merger(input_terminator='0 0\n')
33+
# icpc wf ~2011
34+
#icpc_merger(input_terminator='0 0\n',
35+
# output_replace=casenum_replace('Case 1', 'Case {0}'))
36+
#gcj_merger(output_replace=casenum_replace('Case 1', 'Case {0}'))
37+
id='X'
38+
#merged_testset(name=id + '_Merged', input_pattern='*.in')
39+
#subtask_testset(name='All', score=100, input_patterns=['*'])
40+
# precisely scored by judge program like Jiyukenkyu (KUPC 2013)
41+
#scoring_judge()

Diff for: battle_royal/tests/constraints.h

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const int MAX_T = 100;
2+
const int PLAYERS = 100;

Diff for: battle_royal/tests/generator.cpp

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#include <fstream>
2+
#include <string>
3+
#include <algorithm>
4+
#include <random>
5+
#include "testlib.h"
6+
#include "constraints.h"
7+
using namespace std;
8+
9+
vector<int> random_case(int kill_sum, int killers) {
10+
int remain = kill_sum - killers;
11+
vector<int> K(PLAYERS);
12+
for(int i = 0; i < killers; i++) K[i] = 1;
13+
for(int i = 0; i < remain; i++) {
14+
K[rnd.next(killers)]++;
15+
}
16+
shuffle(K.begin(), K.end());
17+
return K;
18+
}
19+
20+
vector<int> no_kill_case() {
21+
vector<int> K(PLAYERS);
22+
return K;
23+
}
24+
25+
void write_data_set(const string &name, vector< vector<int> > &data_set) {
26+
int T = data_set.size();
27+
ofstream ofs(name);
28+
ofs << T << "\n";
29+
for(int t = 0; t < T; t++) {
30+
for(int i = 0; i < PLAYERS; i++) {
31+
ofs << data_set[t][i] << (i + 1 != PLAYERS ? " " : "\n");
32+
}
33+
}
34+
}
35+
36+
void generate_small() {
37+
vector< vector<int> > data_set;
38+
data_set.push_back(random_case(32, 15));
39+
data_set.push_back(random_case(54, 3));
40+
data_set.push_back(random_case(82, 10));
41+
data_set.push_back(random_case(98, 87));
42+
data_set.push_back(random_case(77, 2));
43+
data_set.push_back(no_kill_case());
44+
write_data_set("small.in", data_set);
45+
}
46+
47+
void generate_large() {
48+
vector< vector<int> > data_set;
49+
for(int t = 0; t < 90; t++) {
50+
int kill_sum = rnd.next(PLAYERS - 2) + 1;
51+
int killers = rnd.next(kill_sum) + 1;
52+
data_set.push_back(random_case(kill_sum, killers));
53+
}
54+
data_set.push_back(random_case(32, 15));
55+
data_set.push_back(random_case(54, 3));
56+
data_set.push_back(random_case(82, 10));
57+
data_set.push_back(random_case(98, 87));
58+
data_set.push_back(random_case(77, 2));
59+
data_set.push_back(random_case(99, 99));
60+
data_set.push_back(random_case(99, 1));
61+
data_set.push_back(random_case(5, 4));
62+
data_set.push_back(random_case(42, 7));
63+
data_set.push_back(no_kill_case());
64+
shuffle(data_set.begin(), data_set.end());
65+
write_data_set("large.in", data_set);
66+
}
67+
68+
void generate(const string &name, int T) {
69+
vector< vector<int> > data_set;
70+
for(int t = 0; t < T; t++) {
71+
int kill_sum = rnd.next(PLAYERS - 2) + 1;
72+
int killers = rnd.next(kill_sum) + 1;
73+
data_set.push_back(random_case(kill_sum, killers));
74+
}
75+
shuffle(data_set.begin(), data_set.end());
76+
write_data_set(name, data_set);
77+
}
78+
79+
int main(int argc, char* argv[]) {
80+
registerGen(argc, argv, 1);
81+
82+
generate_small();
83+
generate_large();
84+
85+
for(int i = 0; i < 10; i++) {
86+
generate("random_test" + to_string(i) + ".in", MAX_T);
87+
}
88+
89+
return 0;
90+
}

Diff for: battle_royal/tests/sample.diff

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
1
2+
80
3+
8
4+
3

Diff for: battle_royal/tests/sample.in

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
4
2+
0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
3+
20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4+
0 0 1 1 0 2 0 0 1 0 0 2 0 2 1 2 0 0 0 1 0 2 1 1 2 1 3 2 0 4 1 0 1 0 1 2 2 1 0 0 1 0 1 1 0 1 1 0 0 1 1 1 0 0 1 0 2 1 1 1 1 0 3 1 1 0 0 4 1 1 2 0 1 2 0 0 2 1 1 0 1 1 2 0 3 0 2 1 1 0 1 1 1 2 0 1 1 0 1 1
5+
1 2 1 1 0 0 1 1 1 1 0 0 1 0 1 1 0 2 1 3 0 2 0 1 2 0 1 2 3 3 0 1 2 0 2 0 1 1 0 2 2 2 0 1 1 1 1 0 0 1 1 2 1 1 0 1 3 0 1 1 0 0 0 0 2 3 0 2 1 0 2 2 0 0 1 2 0 0 1 1 1 1 0 1 0 0 3 1 1 1 0 1 1 1 1 2 1 3 0 0

Diff for: battle_royal/tests/validator.cpp

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include "testlib.h"
2+
#include "constraints.h"
3+
#include <iostream>
4+
#include <numeric>
5+
using namespace std;
6+
7+
void check_case(){
8+
vector<int> k(PLAYERS);
9+
for(int i=0; i<PLAYERS; ++i){
10+
k[i] = inf.readInt(0, 100, format("k[%d]", i));
11+
if(i == PLAYERS-1) inf.readEoln();
12+
else inf.readSpace();
13+
}
14+
15+
// check: 100人のプレイヤーのキル数としてありえない入力は与えられない
16+
int sum_kill = accumulate(k.begin(), k.end(), 0);
17+
ensure(sum_kill <= PLAYERS-1);
18+
}
19+
20+
int main(){
21+
registerValidation();
22+
23+
int cases = inf.readInt(1, MAX_T, "cases");
24+
inf.readEoln();
25+
26+
for(int i=0; i<cases; ++i) check_case();
27+
inf.readEof();
28+
return 0;
29+
}

0 commit comments

Comments
 (0)