Skip to content

Commit d7dbce5

Browse files
authored
Merge pull request #32 from tossy310/shinya/battle_royal
Battle Royal (writer: ShinyaKato)
2 parents 762636b + a0eee5d commit d7dbce5

File tree

16 files changed

+420
-0
lines changed

16 files changed

+420
-0
lines changed

battle_royal/PROBLEM

Lines changed: 17 additions & 0 deletions
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+
)

battle_royal/cpp-ryoissy/SOLUTION

Lines changed: 20 additions & 0 deletions
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)
Lines changed: 24 additions & 0 deletions
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+
}

battle_royal/python-correct/SOLUTION

Lines changed: 18 additions & 0 deletions
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)

battle_royal/python-correct/main.py

Lines changed: 30 additions & 0 deletions
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()

battle_royal/shinya/SOLUTION

Lines changed: 20 additions & 0 deletions
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)

battle_royal/shinya/main.cpp

Lines changed: 23 additions & 0 deletions
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+
}

battle_royal/statement.md

Lines changed: 54 additions & 0 deletions
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+
```

battle_royal/tests/TESTSET

Lines changed: 41 additions & 0 deletions
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()

battle_royal/tests/constraints.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const int MAX_T = 100;
2+
const int PLAYERS = 100;

0 commit comments

Comments
 (0)