Submission Detail

82 / 82 test cases passed.
Status:

Accepted

Runtime: 7681 ms
Memory Usage: 14.3 MB
Submitted: 1 week, 1 day ago
loading
Runtime Error Message:
Last executed input:
Input:
Output:
Expected:

Accepted Solutions Runtime Distribution

500
1000
1500
2000
2500
3000
3500
4000
4500
5000
5500
0.5
1.0
1.5
2.0
2.5
3.0
3.5
python
Runtime (ms)
Distribution (%)

500
1000
1500
2000
2500
3000
3500
4000
4500
5000
5500
1
2
3
Zoom area by dragging across this chart

Accepted Solutions Memory Distribution

13400
13450
13500
13550
13600
13650
13700
13750
13800
13850
13900
13950
14000
14050
14100
5
10
15
python
Memory (KB)
Distribution (%)

13400
13450
13500
13550
13600
13650
13700
13750
13800
13850
13900
13950
14000
14050
14100
5
10
15
Zoom area by dragging across this chart

Invite friends to challenge Dota2 Senate


Submitted Code: 1 week, 1 day ago

Language: python

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
class Solution(object):
def predictPartyVictory(self, senate):
"""
:type senate: str
:rtype: str
"""
num_R = 0
num_D = 0
for c in senate:
if (c == 'R'):
num_R += 1
else:
num_D += 1
while (num_R > 0 and num_D > 0):
for c in range(0,len(senate)):
if (c >= len(senate)):
break
# print("Current senator ",senate[c]," at index ",c)
if (num_R == 0 or num_D == 0):
break
if (senate[c] == 'R'):
if (c == len(senate)-1):
start = 0
else:
start = c+1
# print("start = ",start)
for i in range(start,len(senate)):
if (senate[i] == 'D'):
new_senate = senate[:i] + 'B' + senate[i+1:]
senate = new_senate
# print(". Banned senator D; new senators: ",senate)
num_D -= 1
break
if (i == len(senate)-1 and start != 0):
for j in range(0,c):
if (senate[j] == 'D'):
new_senate = senate[:j] + 'B' + senate[j+1:]
senate = new_senate
# print(". Banned senator D; new senators: ",senate)
num_D -= 1
break
elif (senate[c] == 'D'):
if (c == len(senate)-1):
start = 0
else:
start = c+1
for i in range(start,len(senate)):
if (senate[i] == 'R'):
new_senate = senate[:i] + 'B' + senate[i+1:]
senate = new_senate
# print(". Banned senator R; new senators: ",senate)
num_R -= 1
break
if (i == len(senate)-1 and start != 0):
for j in range(0,c):
if (senate[j] == 'R'):
new_senate = senate[:j] + 'B' + senate[j+1:]
senate = new_senate
# print(". Banned senator R; new senators: ",senate)
num_R -= 1
break
if (num_R == 0):
return "Dire"
else:
return "Radiant"
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX