Skip to content

Commit 3c1e33e

Browse files
chaemonkyuridenamida
authored andcommitted
整数判定において、先頭が0だったり、文字数が20以上だったらFalseにするように (kyuridenamida#172)
* 整数判定において、先頭が0だったり、文字数が20以上だったらFalseにするように * answer.txtを変更 * test_mod_caseをstringに
1 parent 8b6ef3d commit 3c1e33e

File tree

10 files changed

+79
-71
lines changed

10 files changed

+79
-71
lines changed

atcodertools/fmtprediction/predict_types.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,15 @@ def is_float(text):
4848

4949

5050
def is_int(text):
51-
return re.match(r"-?\d+$", text) is not None
51+
if text == "0":
52+
return True
53+
if re.match(r"-?\d+$", text) is None:
54+
return False
55+
if text[0] == "0":
56+
return False
57+
if len(text) > 19 or (text[0] == '-' and len(text) > 20):
58+
return False
59+
return True
5260

5361

5462
def _convert_to_proper_type(value: str) -> Any:

tests/resources/test_codegen/test_mod_case/cpp/generated_code.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
using namespace std;
33

44
const int mod = 998244353;
5-
void solve(long long A, long long B){
5+
void solve(std::string A, std::string B){
66

77
}
88
int main(){
9-
long long A;
10-
scanf("%lld",&A);
11-
long long B;
12-
scanf("%lld",&B);
9+
std::string A;
10+
std::cin >> A;
11+
std::string B;
12+
std::cin >> B;
1313
solve(A, B);
1414
return 0;
1515
}

tests/resources/test_codegen/test_mod_case/cs/generated_code.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ public class Program{
1111

1212
public static void Main(string[] args){
1313
ConsoleInput cin = new ConsoleInput(Console.In, ' ');
14-
long A;
15-
A = cin.ReadLong;
16-
long B;
17-
B = cin.ReadLong;
14+
string A;
15+
A = cin.Read;
16+
string B;
17+
B = cin.Read;
1818
new Program().Solve(A, B);
1919
}
2020

21-
public void Solve(long A, long B){
21+
public void Solve(string A, string B){
2222

2323
}
2424
}

tests/resources/test_codegen/test_mod_case/d/generated_code.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ import std.string;
55

66
immutable long MOD = 998244353;
77

8-
void solve(long A, long B){
8+
void solve(string A, string B){
99

1010
}
1111

1212
int main(){
1313
auto input = stdin.byLine.map!split.joiner;
1414

15-
long A;
16-
A = input.front.to!long;
15+
string A;
16+
A = input.front.to!string;
1717
input.popFront;
1818

19-
long B;
20-
B = input.front.to!long;
19+
string B;
20+
B = input.front.to!string;
2121
input.popFront;
2222

2323
solve(A, B);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[('A', <class 'int'>), ('B', <class 'int'>)]
1+
[('A', <class 'str'>), ('B', <class 'str'>)]

tests/resources/test_codegen/test_mod_case/java/generated_code.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ class Main {
55
static final int mod = 998244353;
66
public static void main(String[] args) throws Exception {
77
final Scanner sc = new Scanner(System.in);
8-
long A;
9-
A = sc.nextLong();
10-
long B;
11-
B = sc.nextLong();
8+
String A;
9+
A = sc.next();
10+
String B;
11+
B = sc.next();
1212
solve(A, B);
1313
}
1414

15-
static void solve(long A, long B){
15+
static void solve(String A, String B){
1616

1717
}
1818
}

tests/resources/test_codegen/test_mod_case/nim/generated_code.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ proc nextString(): string =
1616

1717
let MOD = 998244353
1818

19-
proc solve(A:int, B:int):void =
19+
proc solve(A:string, B:string):void =
2020
return
2121

2222
proc main():void =
23-
var A = 0
24-
A = nextInt()
25-
var B = 0
26-
B = nextInt()
23+
var A = ""
24+
A = nextString()
25+
var B = ""
26+
B = nextString()
2727
solve(A, B)
2828
return
2929

tests/resources/test_codegen/test_mod_case/python/generated_code.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import sys
44
MOD = 998244353 # type: int
55

66

7-
def solve(A: int, B: int):
7+
def solve(A: str, B: str):
88
return
99

1010

@@ -14,8 +14,8 @@ def main():
1414
for word in line.split():
1515
yield word
1616
tokens = iterate_tokens()
17-
A = int(next(tokens)) # type: int
18-
B = int(next(tokens)) # type: int
17+
A = next(tokens) # type: str
18+
B = next(tokens) # type: str
1919
solve(A, B)
2020

2121
if __name__ == '__main__':

tests/resources/test_codegen/test_mod_case/rust/generated_code.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
use std::*;
22

33
const MOD: i64 = 998244353;
4-
fn solve(A: i64, B: i64) {
4+
fn solve(A: String, B: String) {
55

66
}
77

88
fn main() {
99
let con = read_string();
1010
let mut scanner = Scanner::new(&con);
11-
let mut A: i64;
11+
let mut A: String;
1212
A = scanner.next();
13-
let mut B: i64;
13+
let mut B: String;
1414
B = scanner.next();
1515
solve(A, B);
1616
}

tests/resources/test_fmtprediction/answer.txt

Lines changed: 38 additions & 38 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)