質問編集履歴
3
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -80,15 +80,23 @@
|
|
80
80
|
|
81
81
|
for i in range(n):
|
82
82
|
|
83
|
-
if
|
83
|
+
if i != n-1:
|
84
84
|
|
85
|
-
|
85
|
+
if S[i] == "A" or S[i] == "C" or S[i] == "G" or S[i] == "T":
|
86
86
|
|
87
|
-
|
87
|
+
count += 1
|
88
88
|
|
89
|
-
l
|
89
|
+
else:
|
90
90
|
|
91
|
+
li.append(count)
|
92
|
+
|
91
|
-
count = 0
|
93
|
+
count = 0
|
94
|
+
|
95
|
+
if i == n-1:
|
96
|
+
|
97
|
+
count += 1
|
98
|
+
|
99
|
+
li.append(count)
|
92
100
|
|
93
101
|
if len(S) == 1:
|
94
102
|
|
2
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -18,11 +18,23 @@
|
|
18
18
|
|
19
19
|
|
20
20
|
|
21
|
+
追記:
|
22
|
+
|
23
|
+
皆様のアドバイスを受けて、コードを変更しました。
|
24
|
+
|
25
|
+
具体的には、入力が1文字であった時にエラーが起こらないように修正いたしました。
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
修正後のコードを追記します
|
21
30
|
|
22
31
|
|
23
32
|
|
24
33
|
|
34
|
+
|
35
|
+
|
36
|
+
|
25
|
-
###
|
37
|
+
### ソースコード(修正前)
|
26
38
|
|
27
39
|
|
28
40
|
|
@@ -51,3 +63,45 @@
|
|
51
63
|
print(max(li))
|
52
64
|
|
53
65
|
```
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
###ソースコード(修正後)
|
70
|
+
|
71
|
+
```python
|
72
|
+
|
73
|
+
S = list(input())
|
74
|
+
|
75
|
+
n = len(S)
|
76
|
+
|
77
|
+
count = 0
|
78
|
+
|
79
|
+
li = []
|
80
|
+
|
81
|
+
for i in range(n):
|
82
|
+
|
83
|
+
if S[i] == "A" or S[i] == "C" or S[i] == "G" or S[i] == "T":
|
84
|
+
|
85
|
+
count += 1
|
86
|
+
|
87
|
+
else:
|
88
|
+
|
89
|
+
li.append(count)
|
90
|
+
|
91
|
+
count = 0
|
92
|
+
|
93
|
+
if len(S) == 1:
|
94
|
+
|
95
|
+
if S[0] == "A" or S[0] == "C" or S[0] == "G" or S[0] == "T":
|
96
|
+
|
97
|
+
print(1)
|
98
|
+
|
99
|
+
else:
|
100
|
+
|
101
|
+
print(0)
|
102
|
+
|
103
|
+
else:
|
104
|
+
|
105
|
+
print(max(li))
|
106
|
+
|
107
|
+
```
|
1
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
atcoder beginner contest122のB問題"ATcoder"を解いています。
|
6
6
|
|
7
|
-
https://atcoder.jp/contests/abc122/tasks/abc122_b
|
7
|
+
[ABC122 B ATcoder](https://atcoder.jp/contests/abc122/tasks/abc122_b)
|
8
8
|
|
9
9
|
|
10
10
|
|