Skip to content

Commit a234c59

Browse files
author
DAyamaCTF
authored
Merge pull request #24 from tossy310/dayama/gpajanken
GPA JANKEN
2 parents f986dad + f2f9fd3 commit a234c59

File tree

10 files changed

+194
-0
lines changed

10 files changed

+194
-0
lines changed

gpajanken/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 + "GPA JANKEN",
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='c-correct',
13+
)
14+
15+
atcoder_config(
16+
task_id=None # None means a spare
17+
)

gpajanken/c-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)

gpajanken/c-correct/main.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <stdio.h>
2+
3+
int main(){
4+
int T;
5+
scanf("%d", &T);
6+
for(int i = 0; i < T; i++){
7+
int A, B;
8+
scanf("%d %d",&A,&B);
9+
if(A > B){
10+
printf("KATO\n");
11+
}else if(A < B){
12+
printf("SATO\n");
13+
}else{
14+
printf("DRAW\n");
15+
}
16+
}
17+
return 0;
18+
}

gpajanken/statement.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Description
2+
GPA JANKENとは
3+
「じゃんけんをして、じゃんけんの結果に関わらずGPAが高い方が問答無用で勝ち」
4+
というルールのゲームです。
5+
GPAが同じ場合引き分けになります。
6+
(ここでいうGPAとはGanbari Point Accumulateの略で、0から4のいずれかの整数です)
7+
8+
カトー君とサトー君がGPA JANKENをしました。
9+
カトー君のGPAは$A$、サトー君のGPAは$B$です。
10+
カトー君が勝った場合`KATO`、サトー君が勝った場合`SATO`、引き分けの場合`DRAW`と出力してください。
11+
12+
# Constraints
13+
$0 \leq A \leq 4$
14+
$0 \leq B \leq 4$
15+
$A,\ B$は整数
16+
17+
# Input
18+
1つの入力ファイルは複数のテストケースからなる。
19+
20+
入力ファイルの最初の1行目にはテストケースの個数 $T$ が記される $(1 \leq T \leq 100)$。
21+
22+
2行目以降には、$T$個のテストケースが記述されており、各テストケースは次の形式で表される。
23+
24+
```
25+
$A\ B$
26+
```
27+
28+
# Output
29+
各テストケースに対して、GPA JANKENの結果を1行ずつ出力せよ。
30+
31+
# Sample Input
32+
```
33+
3
34+
2 3
35+
4 3
36+
0 0
37+
```
38+
39+
# Sample Output
40+
```
41+
SATO
42+
KATO
43+
DRAW
44+
```

gpajanken/tests/TESTSET

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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', mainclass='tmp/validator/Validator')
13+
#script_validator(src='validator.pl')
14+
15+
## Output judges.
16+
#c_judge(src='judge.c')
17+
#cxx_judge(src='judge.cc', dependency=['testlib.h'], variant=testlib_judge_runner)
18+
#java_judge(src='Judge.java', encoding='UTF-8', mainclass='Judge')
19+
#script_judge(src='judge.py')
20+
21+
## Reactives.
22+
#c_reactive(src='reactive.c')
23+
#cxx_reactive(src='reactive.cc', dependency=['testlib.h', 'reactive.hpp'], variant=kupc_reactive_runner)
24+
#java_reactive(src='Reactive.java', encoding='UTF-8', mainclass='Judge')
25+
#script_reactive(src='reactive.py')
26+
27+
## Extra Testsets.
28+
#icpc_merger(input_terminator='0 0\n') # icpc type
29+
#icpc_merger(input_terminator='0 0\n', output_replace=casenum_replace('Case 1', 'Case {0}')) # icpc wf ~2011
30+
#gcj_merger(output_replace=casenum_replace('Case 1', 'Case {0}'))
31+
id='X'
32+
#merged_testset(name=id + '_Merged', input_pattern='*.in')
33+
#subtask_testset(name='All', score=100, input_patterns=['*'])
34+
#scoring_judge() # precisely scored by judge program like Jiyukenkyu (KUPC 2013)

gpajanken/tests/constraints.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#define MAX_T 100
2+
#define MIN_AB 0
3+
#define MAX_AB 4

gpajanken/tests/generator.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include <fstream>
2+
#include <string>
3+
#include "testlib.h"
4+
#include "constraints.h"
5+
6+
using namespace std;
7+
8+
void generate(const string &file_name, int num_case) {
9+
ofstream ofs(file_name);
10+
ofs << num_case <<endl;
11+
12+
for (int i=0; i<num_case; i++) {
13+
ofs << rnd.next(MIN_AB, MAX_AB) << " ";
14+
ofs << rnd.next(MIN_AB, MAX_AB) << endl;
15+
}
16+
}
17+
18+
int main(int argc, char* argv[]) {
19+
registerGen(argc, argv, 1);
20+
21+
generate("small.in", 10);
22+
generate("large.in", MAX_T);
23+
for (int i=0; i<10; i++) {
24+
generate("random_test" + to_string(i) + ".in", MAX_T);
25+
}
26+
27+
return 0;
28+
}

gpajanken/tests/sample.diff

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SATO
2+
KATO
3+
DRAW

gpajanken/tests/sample.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
3
2+
2 3
3+
4 3
4+
0 0

gpajanken/tests/validator.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include "testlib.h"
2+
#include "constraints.h"
3+
#include <iostream>
4+
using namespace std;
5+
6+
void check_case(){
7+
int a = inf.readInt(MIN_AB, MAX_AB, "a");
8+
inf.readSpace();
9+
int b = inf.readInt(MIN_AB, MAX_AB, "b");
10+
inf.readEoln();
11+
}
12+
13+
int main(){
14+
registerValidation();
15+
16+
int cases = inf.readInt(1, MAX_T, "cases");
17+
inf.readEoln();
18+
19+
for(int i=0; i<cases; ++i){
20+
check_case();
21+
}
22+
23+
inf.readEof();
24+
return 0;
25+
}

0 commit comments

Comments
 (0)