s_id stringlengths 10 10 | p_id stringlengths 6 6 | u_id stringlengths 10 10 | date stringlengths 10 10 | language stringclasses 1
value | original_language stringclasses 11
values | filename_ext stringclasses 1
value | status stringclasses 1
value | cpu_time int64 0 100 | memory stringlengths 4 6 | code_size int64 15 14.7k | code stringlengths 15 14.7k | problem_id stringlengths 6 6 | problem_description stringlengths 358 9.83k | input stringlengths 2 4.87k | output stringclasses 807
values | __index_level_0__ int64 1.1k 1.22M |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s608285616 | p00066 | u964040941 | 1490417972 | Python | Python3 | py | Accepted | 20 | 7344 | 467 | c = [[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]]
while True:
try:
S = input()
except EOFError:
break
for i in c:
o = True
x = True
for j in i:
if S [j] != 'o':
o = False
if S [j] != 'x':
x =... | p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,341 |
s033272468 | p00066 | u462831976 | 1493167789 | Python | Python3 | py | Accepted | 30 | 7548 | 661 | # -*- coding: utf-8 -*-
import sys
import os
import re
def is_win(A, B, C, sign):
if A[0] == A[1] == A[2] == sign or B[0] == B[1] == B[2] == sign or C[0] == C[1] == C[2] == sign:
return True
elif A[0] == B[0] == C[0] == sign or A[1] == B[1] == C[1] == sign or A[2] == B[2] == C[2] == sign:
retu... | p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,342 |
s289808136 | p00066 | u546285759 | 1495624645 | Python | Python3 | py | Accepted | 20 | 7372 | 465 | while True:
try:
hoge = input()
except:
break
ans = "d"
for i in range(3):
if "ooo" == hoge[i*3:i*3+3] or "ooo" == hoge[i::3]:
ans = "o"
break
elif "xxx" == hoge[i*3:i*3+3] or "xxx" == hoge[i::3]:
ans = "x"
break
if hoge... | p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,343 |
s600824708 | p00066 | u811733736 | 1503449762 | Python | Python3 | py | Accepted | 30 | 7568 | 2,357 | # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0066
"""
import sys
def prepare_board(size=3):
return [[1]*size for _ in range(size)]
def check_horizontal(status):
dp = prepare_board()
for y in range(len(status)):
for x in range(1, len(status[0])):
... | p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,344 |
s136368541 | p00066 | u957021183 | 1505109317 | Python | Python3 | py | Accepted | 20 | 7524 | 989 | # Aizu Problem 0066: Tic-Tac-Toe
#
import sys, math, os
# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
sys.stdin = open("sample-input.txt", "rt")
def check_triple(triple):
# check whether a triple of values is a winning position:
return len(set(triple)) == 1 and triple[0] != 's'
de... | p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,345 |
s918159333 | p00066 | u150984829 | 1514697360 | Python | Python3 | py | Accepted | 20 | 5564 | 234 | import sys
t={'o':1,'x':-1,'s':0}
for l in sys.stdin:
d=[t[s]for s in l.strip()]
a=[sum(d[0:3]),sum(d[3:6]),sum(d[6:]),sum(d[0::3]),sum(d[1::3]),sum(d[2::3]),sum(d[0::4]),sum(d[2:8:2])]
print('o'if 3 in a else'x'if -3 in a else'd') | p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,346 |
s490277370 | p00066 | u150984829 | 1514698005 | Python | Python3 | py | Accepted | 20 | 5572 | 210 | import sys
t={'o':1,'x':-1,'s':0}
for l in sys.stdin:
d=[t[s]for s in l.strip()]
a=[sum(s)for s in(d[0:3],d[3:6],d[6:],d[0::3],d[1::3],d[2::3],d[0::4],d[2:8:2])]
print('o'if 3 in a else'x'if -3 in a else'd') | p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,347 |
s030863551 | p00066 | u150984829 | 1514698895 | Python | Python3 | py | Accepted | 20 | 5572 | 206 | import sys
for l in sys.stdin:
d=[{'o':1,'x':-1,'s':0}[s]for s in l.strip()]
a=[sum(s)for s in(d[0:3],d[3:6],d[6:],d[0::3],d[1::3],d[2::3],d[0::4],d[2:8:2])]
print('o'if 3 in a else'x'if -3 in a else'd') | p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,348 |
s055087907 | p00066 | u024715419 | 1518501509 | Python | Python3 | py | Accepted | 20 | 5560 | 546 | while True:
try:
s = input()
if s[4] != "s":
if (s[0] == s[4] and s[0] == s[8]) or (s[2] == s[4] and s[2] == s[6]):
print(s[4])
continue
for i in range(3):
if s[i] != "s" and s[i] == s[i + 3] and s[i] == s[i + 6]:
print(... | p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,349 |
s795698655 | p00066 | u043254318 | 1518718262 | Python | Python3 | py | Accepted | 20 | 5576 | 1,012 | def get_input():
while True:
try:
yield ''.join(input())
except EOFError:
break
N = list(get_input())
for l in range(len(N)):
table = [[0 for i in range(3)] for j in range(3)]
S = N[l]
ans = "d"
for i in range(9):
if S[i] == "o":
table[i ... | p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,350 |
s378456791 | p00066 | u150984829 | 1520109783 | Python | Python3 | py | Accepted | 20 | 5572 | 196 | import sys
for l in sys.stdin:
d=[{'o':1,'x':-1,'s':0}[s]for s in l.strip()]
a=[sum(s)for s in(d[0:3],d[3:6],d[6:],d[0::3],d[1::3],d[2::3],d[0::4],d[2:8:2])]
print(['dx'[-3 in a],'o'][3 in a])
| p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,351 |
s000059161 | p00066 | u150984829 | 1520109918 | Python | Python3 | py | Accepted | 20 | 5568 | 194 | import sys
for e in sys.stdin:
d=[{'o':1,'x':-1,'s':0}[s]for s in e.strip()]
a=[sum(s)for s in(d[0:3],d[3:6],d[6:],d[0::3],d[1::3],d[2::3],d[0::4],d[2:8:2])]
print('dxo'[(-3in a)+(3in a)*2])
| p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,352 |
s745477455 | p00066 | u352394527 | 1527542576 | Python | Python3 | py | Accepted | 20 | 5564 | 566 | def check(s):
for i in (0, 3, 6): #横
if s[i] != "s" and s[i] == s[i + 1] and s[i + 1] == s[i + 2]:
print(s[i])
return
for i in (0, 1, 2): #縦
if s[i] != "s" and s[i] == s[i + 3] and s[i + 3] == s[i + 6]:
print(s[i])
return
if s[0] != "s" and s[0] == s[4] and s[4] == s[8]: #斜め1
... | p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,353 |
s957936453 | p00066 | u136916346 | 1527949316 | Python | Python3 | py | Accepted | 30 | 5568 | 343 | import sys
def ttt(o):
if (o[0]==o[4]==o[8] or o[2]==o[4]==o[6]) and o[4]!="s":
return o[4]
for i in range(3):
if o[i*3]!="s" and o[i*3]==o[i*3+1]==o[i*3+2]:
return o[i*3]
if o[i]!="s" and o[i]==o[i+3]==o[i+6]:
return o[i]
return "d"
[print(ttt(j)) for j in [i... | p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,354 |
s035684499 | p00066 | u847467233 | 1529148616 | Python | Python3 | py | Accepted | 20 | 5572 | 697 | # AOJ 0066 Tic Tac Toe
# Python3 2018.6.15 bal4u
arr = [[0 for r in range(3)] for c in range(3)]
koma = { 'o':1, 'x':-1, 's':0 }
while True:
try: a = list(input())
except: break
for i in range(len(a)): arr[i//3][i%3] = koma[a[i]]
end = False
for r in range(3):
d = 0;
for c in range(3): d += arr[r][c]
if d... | p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,355 |
s791434542 | p00066 | u847467233 | 1529150235 | Python | Python3 | py | Accepted | 20 | 5564 | 344 | # AOJ 0066 Tic Tac Toe
# Python3 2018.6.15 bal4u
def check(a):
for koma in ['o', 'x']:
for i in range(3):
if a[i:9:3].count(koma) == 3 or a[3*i:3*i+3].count(koma) == 3: return koma
if a[0:9:4].count(koma) == 3 or a[2:7:2].count(koma) == 3: return koma
return 'd'
while True:
try: print(check(list(input())))
... | p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,356 |
s818387822 | p00066 | u759949288 | 1352628486 | Python | Python | py | Accepted | 20 | 4248 | 407 | import sys
def win(c, line):
for i in range(0, 9, 3):
if all(p == c for p in line[i:i + 3:1]):
return True
for i in range(3):
if all(p == c for p in line[i:i + 9:3]):
return True
if all(p == c for p in line[0::4]): return True
if all(p == c for p in line[2:8:2]): return True
return False;
for line in sys... | p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,357 |
s575908112 | p00066 | u647766105 | 1356473305 | Python | Python | py | Accepted | 20 | 4248 | 497 | import sys
for line in sys.stdin.readlines():
result="d"
for i in xrange(3):
if not line[3*i]=="s" and line[3*i]==line[3*i+1] and line[3*i]==line[3*i+2]:
result=line[3*i]
if not line[i]=="s" and line[i]==line[i+3] and line[i]==line[i+6]:
result=line[i]
if not line[0]=... | p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,358 |
s317542990 | p00066 | u104911888 | 1364468356 | Python | Python | py | Accepted | 20 | 4276 | 808 | while (1):
try:
s=raw_input()
except EOFError:
break
B=False
if s[0]==s[4]==s[8]=="o":
print "o"
B=True
elif s[0]==s[4]==s[8]=="x":
print "x"
B=True
if s[2]==s[4]==s[6]=="o":
print "o"
B=True
elif s[2]==s[4]==s[6]=="x":
... | p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,359 |
s840617471 | p00066 | u104911888 | 1367482269 | Python | Python | py | Accepted | 20 | 4240 | 315 | while True:
try:
s=raw_input()
except EOFError:
break
L=[(i,i+1,i+2) for i in range(0,9,3)]+[(i,i+3,i+6) for i in range(3)]+[(0,4\
,8),(2,4,6)]
for i,j,k in L:
if s[i]==s[j]==s[k]!="s":
print "o" if s[i]=="o" else "x"
break
else:
print "d" | p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,360 |
s361381817 | p00066 | u915761101 | 1369217726 | Python | Python | py | Accepted | 10 | 4244 | 375 | def get_winner(s):
for p in ['o','x']:
for i in xrange(3):
win_h=True
win_v=True
for j in xrange(3):
if s[i*3+j]!=p:
win_h=False
if s[j*3+i]!=p:
win_v=False
if win_h or win_v:
return p
if p==s[0]==s[4]==s[8] or p==s[2]==s[4]==s[6]:
return p
return 'd'
while 1:
try:
s=raw_i... | p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,361 |
s861979685 | p00066 | u542421762 | 1370923205 | Python | Python | py | Accepted | 10 | 4256 | 640 |
import sys
def solv(b):
if judge(b, 0, 1, 2):
return b[0]
elif judge(b, 3, 4, 5):
return b[3]
elif judge(b, 6, 7, 8):
return b[6]
elif judge(b, 0, 3, 6):
return b[0]
elif judge(b, 1, 4, 7):
return b[1]
elif judge(b, 2, 5, 8):
return b[2]
eli... | p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,362 |
s351154479 | p00066 | u782850731 | 1377505954 | Python | Python | py | Accepted | 20 | 4280 | 714 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
unicode_literals)
from sys import stdin
condition = ('ooo', 'xxx')
for line in stdin:
if line[0:3] in condition:
win = line[0]
elif line[3:6] in condition:
wi... | p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,363 |
s534909255 | p00066 | u093607836 | 1382882398 | Python | Python | py | Accepted | 20 | 4380 | 581 | import sys,itertools
ans = ['xxx ',' xxx ',' xxx','x x x ',' x x x ',' x x x','x x x',' x x x ']
for s in sys.stdin:
s = s.strip()
o = [True if c == 'o' else False for c in s]
x = [True if c == 'x' else False for c in s]
o = list(itertools.repeat(0,len(ans)))
x = list(itertools.repeat(0... | p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,364 |
s192431689 | p00066 | u912237403 | 1390005897 | Python | Python | py | Accepted | 10 | 4228 | 350 | import sys
for s in sys.stdin:
c="d"
for i in range(3):
a=s[i]
if a!="s"and a==s[i+3]==s[i+6]:
c=a
break
j=i*3
a=s[j]
if a!="s"and a==s[j+1]==s[j+2]:
c=a
break
else:
a=s[4]
if a!="s"and (s[0]==a==s[8] or ... | p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,365 |
s637008420 | p00066 | u912237403 | 1390007757 | Python | Python | py | Accepted | 20 | 4220 | 287 | import sys
x=["ooo","xxx"]
for s in sys.stdin:
c="d"
for i in range(3):
if s[i:9:3]in x:
c=s[i]
break
j=i*3
if s[j:j+3]in x:
c=s[j]
break
else:
if s[0::4] in x or s[2:7:2] in x:c=s[4]
print c | p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,366 |
s241553658 | p00066 | u912237403 | 1390009805 | Python | Python | py | Accepted | 10 | 4216 | 307 | import sys
def f(a,b,c):
return a if a!="s"and a==b==c else 0
for s in sys.stdin:
for i in range(3):
c=f(*s[i:9:3])
if c: break
j=i*3
c=f(*s[j:j+3])
if c: break
else:
a=s[4]
if f(*s[0:9:4])or f(*s[2:7:2]):c=a
else:c="d"
print c | p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,367 |
s460084471 | p00066 | u912237403 | 1390009968 | Python | Python | py | Accepted | 20 | 4216 | 297 | import sys
def f(a,b,c):
return a if a!="s"and a==b==c else 0
for s in sys.stdin:
for i in range(3):
c=f(*s[i:9:3])
if c: break
j=i*3
c=f(*s[j:j+3])
if c: break
else:
a=s[4]
c=a if f(*s[0:9:4])or f(*s[2:7:2]) else "d"
print c | p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,368 |
s342619233 | p00066 | u912237403 | 1390010083 | Python | Python | py | Accepted | 10 | 4220 | 297 | import sys
def f(a,b,c):
return a if a!="s"and a==b==c else 0
for s in sys.stdin:
for i in range(3):
c=f(*s[i:9:3])
if c: break
j=i*3
c=f(*s[j:j+3])
if c: break
else:
a=s[4]
c=a if f(*s[0:9:4])or f(*s[2:7:2]) else "d"
print c | p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,369 |
s309343580 | p00066 | u912237403 | 1390010292 | Python | Python | py | Accepted | 10 | 4216 | 285 | import sys
def f(a,b,c):
return a if a!="s"and a==b==c else 0
for s in sys.stdin:
for i in range(3):
c=f(*s[i:9:3])
if c: break
j=i*3
c=f(*s[j:j+3])
if c: break
else:
c=s[4] if f(*s[0:9:4])or f(*s[2:7:2]) else "d"
print c | p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,370 |
s236445348 | p00066 | u633068244 | 1393693949 | Python | Python | py | Accepted | 10 | 4220 | 573 | while True:
try:
a = raw_input()
if a[::4] == "ooo" or a[2:8:2] == "ooo":
print "o"
elif a[::4] == "xxx" or a[2:8:2] == "xxx":
print "x"
else:
for i in range(3):
if a[3*i:3*(i+1)] == "ooo" or a[i::3] == "ooo":
pr... | p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,371 |
s848503699 | p00066 | u708217907 | 1399790457 | Python | Python | py | Accepted | 10 | 4220 | 374 | def judge(a, b, c):
return a if a == b == c and a != 's' else 0
while True:
try:
s = raw_input()
for i in range(3):
result = judge(*s[i:9:3])
if result: break
result = judge(*s[3*i:3*i+3])
if result: break
else:
result = s[4] if s[4] != 's' and (judge(*s[0:9:4]) or judge(*... | p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,372 |
s874801176 | p00066 | u436634575 | 1402301018 | Python | Python3 | py | Accepted | 30 | 6716 | 310 | while True:
try:
ban = input()
except EOFError:
break
s = [ban[:3], ban[3:6], ban[6:]]
s += map(''.join, zip(*s))
s += [ban[0]+ban[4]+ban[8]] + [ban[2]+ban[4]+ban[6]]
if 'ooo' in s:
print('o')
elif 'xxx' in s:
print('x')
else:
print('d') | p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,373 |
s284238812 | p00066 | u187074069 | 1595170540 | Python | Python3 | py | Accepted | 20 | 5560 | 745 | while True:
try:
k = list(input())
ans = 'd'
lst1 = [k[:3], k[3:6], k[6:]]
lst2 = [k[::3], k[1::3], k[2::3]]
if k[4] != 's':
if k[0] == k[4] and k[4] == k[8]:
ans = k[4]
elif k[2] == k[4] and k[4] == k[6]:
ans = k[4]
... | p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,374 |
s511609832 | p00066 | u260980560 | 1590284380 | Python | Python3 | py | Accepted | 20 | 5572 | 537 | import sys
readlines = sys.stdin.readlines
write = sys.stdout.write
P = [
(0, 1, 2), (3, 4, 5), (6, 7, 8),
(0, 3, 6), (1, 4, 7), (2, 5, 8),
(0, 4, 8), (2, 4, 6),
]
def solve():
for line in readlines():
s = line.strip()
for a, b, c in P:
if s[a] == s[b] == s[c]:
... | p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,375 |
s068455232 | p00066 | u630911389 | 1583686294 | Python | Python3 | py | Accepted | 20 | 5572 | 1,134 | table = [[''] * 3 for i in range(3)]
def ans():
r = 0
c = 1
# 横
while(r < 3):
char = table[r][0]
if char != 's':
c = 1
while(c < 3):
if table[r][c] != char:
break
if table[r][c] == char and c + 1 >= 3:
... | p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,376 |
s992287345 | p00066 | u606731189 | 1577254480 | Python | Python3 | py | Accepted | 20 | 5560 | 682 | def cross(s):
if s[0]==s[4]==s[8] and s[0]!="s":
print(s[0])
return True
elif s[2]==s[4]==s[6] and s[2]!="s":
print(s[2])
return True
else:
return False
def side(s):
for i in range(0,len(s),3):
if s[i]==s[i+1]==s[i+2] and s[i]!="s":
print(s[i]... | p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,377 |
s704832385 | p00066 | u803862921 | 1573210086 | Python | Python3 | py | Accepted | 20 | 5556 | 426 | while True:
try:
s = input().rstrip()
except:
break
win = None
for i, j, k in ((0,1,2),(3,4,5),(6,7,8),(0,3,6),(1,4,7),(2,5,8),(0,4,8),(2,4,6)):
chk = s[i] + s[j] + s[k]
if chk == "ooo":
win = "o"
break
elif chk == "xxx":
win = ... | p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,378 |
s371308290 | p00066 | u824708460 | 1567136236 | Python | Python3 | py | Accepted | 20 | 5560 | 330 | def f(s):
for t in ['o', 'x']:
if s[::4].count(t) == 3 or s[2:7:2].count(t) == 3:
return t
for i in range(3):
if s[i::3].count(t) == 3 or s[3 * i:3 * i + 3].count(t) == 3:
return t
return 'd'
while 1:
try:
print(f(input()))
except:
... | p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,379 |
s577532681 | p00066 | u548252256 | 1561645757 | Python | Python3 | py | Accepted | 30 | 5596 | 1,345 | if __name__ == '__main__':
while True:
try:
line = list(input())
ans = "d"
if line[0] == "o" and line[4] == "o" and line[8] == "o":
ans = "o"
elif line[2] == "o" and line[4] == "o" and line[6] == "o":
ans = "o"
elif line[0] == "o" and line[3] == "o" and line[6] == "o":
ans = "o"
elif... | p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,380 |
s853038754 | p00066 | u990228206 | 1553153050 | Python | Python3 | py | Accepted | 20 | 5560 | 568 | while 1:
try:
s=input()
if s[0]==s[1]==s[2]!="s":
print(s[0])
elif s[3]==s[4]==s[5]!="s":
print(s[3])
elif s[6]==s[7]==s[8]!="s":
print(s[6])
elif s[0]==s[3]==s[6]!="s":
print(s[0])
elif s[1]==s[4]==s[7]!="s":
... | p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,381 |
s824367626 | p00066 | u563075864 | 1544584951 | Python | Python3 | py | Accepted | 20 | 5568 | 486 | while(1):
try:
faces = [1 if i == "o" else 0 for i in list(input())]
hori = [sum(faces[0:3]),sum(faces[3:6]),sum(faces[6:9])]
vert = [sum(faces[0:7:3]),sum(faces[1:8:3]),sum(faces[2:9:3])]
diag = [sum(faces[0:9:4]),sum(faces[2:7:2])]
hori.extend(vert)
hori.extend(diag... | p00066 |
<H1>三目並べ</H1>
<p>
三目並べは,3 × 3のマス目の中に交互に ○ と × を入れていき、縦・横・斜めの何れかに一列 ○ か × が並んだときに、勝ちとなるゲームです(図1〜図3 を参照)
</p>
<center>
<table>
<tr>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic1"></td>
<td width="140"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_tic2"><... | ooosxssxs
xoosxsosx
ooxxxooxo
| o
x
d
| 11,382 |
s081098074 | p00067 | u197615397 | 1531228024 | Python | Python3 | py | Accepted | 30 | 6016 | 756 | from collections import deque
dq = deque()
append, popleft = dq.append, dq.popleft
try:
while True:
a = [[0]*14] + [[0]+list(map(int,input()))+[0] for _ in [0]*12] + [[0]*14]
result = 0
for y in range(1, 13):
for x in filter(lambda x: a[y][x], range(1, 13)):
resul... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,383 |
s793887363 | p00067 | u647694976 | 1559031025 | Python | Python3 | py | Accepted | 30 | 5580 | 381 | c=0
def f(a,x,y):
if 0<=x<12 and 0<=y<12 and a[y][x]=='1':
a[y][x]='0'
for dx,dy in [[-1,0],[1,0],[0,-1],[0,1]]:f(a,x+dx,y+dy)
while 1:
try:
if c:input()
except:break
a = [list(input()) for _ in [0]*12]
c=1;b=0
for i in range(12):
for j in range(12):
... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,384 |
s397588046 | p00067 | u093607836 | 1407609004 | Python | Python3 | py | Accepted | 40 | 6756 | 934 | import itertools
def getPoint(m,x,y):
if not (0 <= x < 12) or not (0 <= y < 12):
return 0
return m[y][x]
def setPoint(m,x,y,v):
m[y][x] = v
while 1:
try:
m = [list(map(int,input().strip())) for _ in range(12)]
count = 0
empty = False
while not empty:
... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,385 |
s853443696 | p00067 | u193025715 | 1408888805 | Python | Python3 | py | Accepted | 30 | 6744 | 768 | def fill(x, y, board):
board[y][x] = 2
points = [[y, x + 1], [y, x - 1], [y + 1, x], [y - 1, x]]
if y == 0:
points.remove([y-1, x])
elif y == 11:
points.remove([y+1, x])
if x == 0:
points.remove([y, x - 1])
elif x == 11:
points.remove([y, x + 1])
for p in po... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,386 |
s116709657 | p00067 | u506132575 | 1417227650 | Python | Python | py | Accepted | 20 | 4500 | 726 | import itertools
import sys
def delete(ya,xa,lis):
lis[ya][xa] = 0
move = [[-1,0],[0,-1],[1,0],[0,1]]
for x,y in move:
if 0<=xa+x<=11 and 0<=ya+y<=11 and lis[ya+y][xa+x]=='1':
delete(ya+y,xa+x,lis)
def sol(a,b,lis):
for i,j in itertools.product(xrange(12),repeat=2):
if lis[... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,387 |
s279389881 | p00067 | u586434734 | 1421758171 | Python | Python | py | Accepted | 20 | 4360 | 1,319 | #! /usr/bin/python
# -*- coding: utf-8 -*-
MAX_Y = 12
MAX_X = 12
XY = ((-1, 0), (1, 0), (0, -1), (0, 1))
def main():
# input
while(True):
try:
data = []
for j in range(MAX_Y):
input_list = map(int, raw_input())
data.append(input_list)
... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,388 |
s417762700 | p00067 | u567380442 | 1424677396 | Python | Python3 | py | Accepted | 30 | 6724 | 598 | import sys
f = sys.stdin
def paintout0(islands, x, y):
if 0 <= x <12 and 0 <= y <12 and islands[y][x]:
islands[y][x] = 0
paintout0(islands,x + 1,y)
paintout0(islands,x,y + 1)
paintout0(islands,x -1,y)
paintout0(islands,x,y -1)
while True:
islands = [[int(c) for c in f.... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,389 |
s211155757 | p00067 | u873482706 | 1434941707 | Python | Python | py | Accepted | 20 | 4376 | 878 | import sys
def quartet(h, w):
global flag
if 0 <= h <= 11 and 0 <= w <= 11:
if mapp[h][w] == '1':
mapp[h][w] = '$'
flag = True
bigbang(h, w)
elif mapp[h][w] == '0' or mapp[h][w] == '$':
return
else:
return
def bigbang(h, w):
quart... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,390 |
s709249287 | p00067 | u489809100 | 1447517834 | Python | Python | py | Accepted | 20 | 6276 | 695 | def fact(y, x1, x2):
island[y] = island[y][:x1] + "0" + island[y][x2:]
if island[y-1][x1:x2] == "1":
fact(y-1, x1, x2)
if island[y+1][x1:x2] == "1":
fact(y+1, x1, x2)
if island[y][x1-1:x2-1] == "1":
fact(y, x1 - 1, x2 - 1)
if island[y][x1+1:x2+1] == "1":
fact(y, x1 + 1, x2 + 1)
while True:
island = []
f... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,391 |
s171004292 | p00067 | u140201022 | 1451279847 | Python | Python | py | Accepted | 10 | 6384 | 948 | xy=[(1,0),(-1,0),(0,1),(0,-1)]
bs=[(-1,-1),(-1,1),(1,1),(1,-1)]
def gcd(a,b): return a if b==0 else gcd(b,a%b)
def lcm(a,b): return a*b/gcd(a,b)
def choco(xa,ya,xb,yb,xc,yc,xd,yd): return 1 if abs((yb-ya)*(yd-yc)+(xb-xa)*(xd-xc))<1.e-10 else 0
def sol(l,a,b):
q=[[a,b]]
while len(q):
chk=q.pop()
... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,392 |
s568007095 | p00067 | u529386725 | 1452714083 | Python | Python | py | Accepted | 10 | 6384 | 604 | N = 12
di = [1, 0, -1, 0]
dj = [0, 1, 0, -1]
def dfs(i, j):
field[i][j] = '0'
for k in xrange(4):
ni = i + di[k]
nj = j + dj[k]
if 0 <= ni < N and 0 <= nj < N and field[ni][nj] == '1':
dfs(ni, nj)
return;
while True:
try:
field = []
for i in xrange(N... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,393 |
s041841102 | p00067 | u797673668 | 1453046148 | Python | Python3 | py | Accepted | 30 | 7812 | 652 | def search_neighbor(sea, x, y):
global dir_x, dir_y
for i in range(4):
nx, ny = x + dir_x[i], y + dir_y[i]
if not 0 <= nx < 12 or not 0 <= ny < 12:
continue
if sea[ny][nx]:
sea[ny][nx] = 0
search_neighbor(sea, nx, ny)
dir_x = (1, -1, 0, 0)
dir_y = (0... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,394 |
s402731869 | p00067 | u873482706 | 1458455353 | Python | Python3 | py | Accepted | 50 | 7476 | 843 | def f1():
t = 0
for y, line in enumerate(M):
for x, cell in enumerate(line):
if M[y][x] == '1':
f2(x, y)
t += 1
return t
def f2(x, y):
if x < 0 or len(M[0]) == x or y < 0 or len(M) == y:
return
if M[y][x] == '1':
M[y][x] = '0'
... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,395 |
s147898781 | p00067 | u873482706 | 1458455947 | Python | Python3 | py | Accepted | 30 | 7624 | 654 | def f1():
t = 0
for y, line in enumerate(M):
for x, cell in enumerate(line):
if M[y][x] == '1':
f2(x, y)
t += 1
return t
def f2(x, y):
if x < 0 or len(M[0]) == x or y < 0 or len(M) == y:
return
if M[y][x] == '1':
M[y][x] = '0'
... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,396 |
s663956071 | p00067 | u873482706 | 1458456206 | Python | Python3 | py | Accepted | 30 | 7472 | 613 | def f1():
t = 0
for y, line in enumerate(M):
for x, cell in enumerate(line):
if M[y][x] == '1':
f2(x, y)
t += 1
return t
def f2(x, y):
if x < 0 or len(M[0]) == x or y < 0 or len(M) == y:
return
if M[y][x] == '1':
M[y][x] = '0'
... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,397 |
s482470032 | p00067 | u873482706 | 1458457214 | Python | Python3 | py | Accepted | 30 | 7472 | 603 | def f1():
t = 0
for y in range(len(M)):
for x in range(len(M[0])):
if M[y][x] == '1':
f2(x, y)
t += 1
return t
def f2(x, y):
if x < 0 or len(M[0]) == x or y < 0 or len(M) == y:
return
if M[y][x] == '1':
M[y][x] = '0'
f2(x,... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,398 |
s053179492 | p00067 | u894114233 | 1468563067 | Python | Python | py | Accepted | 10 | 6324 | 626 | def check(y,x):
if 0<=y<=11 and 0<=x<=11:
return True
return False
def dfs(y,x):
if g[y][x]=="0":return 0
g[y][x]="0"
for i in xrange(4):
nexty=y+dy[i]
nextx=x+dx[i]
if not check(nexty,nextx):continue
if visited[nexty][nextx]==0 and g[nexty][nextx]=="1":
visited[nexty][nextx]=1
dfs(nexty,nextx)
... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,399 |
s316488390 | p00067 | u685815919 | 1473649561 | Python | Python | py | Accepted | 20 | 6512 | 600 | H, W = 12, 12
dxy = [[1, 0], [0, 1], [-1, 0], [0, -1]]
field = []
def solver(x, y):
global field
if x < 0 or y < 0 or x >= H or y >= W:
return
for dx, dy in dxy:
if x+dx < 0 or y+dy < 0 or x+dx >= H or y+dy >= W:
continue
if field[x+dx][y+dy] == 1:
field[x+dx][y+dy] = 0
solver(x+dx,... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,400 |
s717153741 | p00067 | u921312486 | 1483089510 | Python | Python3 | py | Accepted | 30 | 7716 | 470 | import sys
def solve(f, i, j):
if 0<=i<12 and 0<=j<12 and f[j][i] == 1:
f[j][i] = 0
for dx, dy in [[0,1],[0,-1],[1,0],[-1,0]]: solve(f, i+dx, j+dy)
while True:
field = [[int(c) for c in sys.stdin.readline().strip()] for _ in range(12)]
ans = 0
for i in range(12):
for j in range... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,401 |
s188360211 | p00067 | u078042885 | 1486669735 | Python | Python3 | py | Accepted | 30 | 7472 | 379 | c=0
def f(a,x,y):
if 0<=x<12 and 0<=y<12 and a[y][x]=='1':
a[y][x]='0'
for dx,dy in [[-1,0],[1,0],[0,-1],[0,1]]:f(a,x+dx,y+dy)
while 1:
try:
if c:input()
except:break
a = [list(input()) for _ in [0]*12]
c=1;b=0
for i in range(12):
for j in range(12):
... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,402 |
s425044078 | p00067 | u078042885 | 1486670323 | Python | Python3 | py | Accepted | 30 | 7368 | 386 | def f(a,x,y):
if 0<=x<12 and 0<=y<12 and a[y][x]=='1':
a[y][x]='0'
for dx,dy in [[-1,0],[1,0],[0,-1],[0,1]]:f(a,x+dx,y+dy)
while 1:
try:
a=[list(input()) for _ in [0]*12]
b=0
for i in range(12):
for j in range(12):
if a[j][i]=='1':
... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,403 |
s347572725 | p00067 | u104171359 | 1487746316 | Python | Python3 | py | Accepted | 20 | 7760 | 833 | #!usr/bin/env python3
import sys
def eliminate_ones(grid, row, col):
if 0 <= row < 12 and 0 <= col < 12 and grid[row][col] == 1:
grid[row][col] = 0
eliminate_ones(grid, row+1, col)
eliminate_ones(grid, row-1, col)
eliminate_ones(grid, row, col+1)
eliminate_ones(grid, row, ... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,404 |
s264164022 | p00067 | u227162786 | 1490005639 | Python | Python3 | py | Accepted | 30 | 7728 | 652 | def dfs(i, j, m):
'''
m[i][j]??¨????????£??????????????°????????????????????????
'''
m[i][j] = 0
for di, dj in [(-1, 0), (1, 0), (0, -1), (0, 1)]:
ni = i + di
nj = j + dj
if ni in range(12) and nj in range(12) and m[ni][nj] == 1:
dfs(ni, nj, m)
wh... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,405 |
s303849829 | p00067 | u964040941 | 1490230595 | Python | Python3 | py | Accepted | 30 | 7444 | 704 | N = 12
dx = [0,1,0,-1]
dy = [-1,0,1,0]
def dfs(y,x,vis,S):
vis [y] [x] = True
for i in range(len(dx)):
ny = y + dy [i]
nx = x + dx [i]
if (ny >= 0 and ny < N and nx >= 0 and nx < N) == False:
continue
if S [ny] [nx] == '1' and vis [ny] [nx] == False:
dfs(... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,406 |
s860695270 | p00067 | u756426560 | 1490909495 | Python | Python3 | py | Accepted | 30 | 7732 | 590 | def remove_linked(x, y, DATA):
DATA[x][y]=0# clear
move = [[1, 0], [0, 1], [-1, 0], [0, -1]]#left, right, down, up
for i, j in move:
nx,ny=x+i,y+j#next x and y
if -1<nx<12 and -1<ny<12 and DATA[nx][ny]:
DATA=remove_linked(nx, ny, DATA)
return DATA
while 1:
DATA = [[int(x... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,407 |
s583891416 | p00067 | u462831976 | 1493262213 | Python | Python3 | py | Accepted | 30 | 7492 | 1,364 | # -*- coding: utf-8 -*-
import sys
import os
def solve(island):
visited = []
for lst in island:
visit_row = []
for c in lst:
if c == '1':
visit_row.append(False)
else:
visit_row.append(True)
visited.append(visit_row)
def pain... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,408 |
s420995704 | p00067 | u811733736 | 1503297465 | Python | Python3 | py | Accepted | 30 | 7848 | 3,010 | # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0067
"""
import sys
def solve(map):
num_of_land = 0
work = []
lmap = map[:]
for i in range(1, len(map)):
for j in range(1, len(map[0])):
if lmap[i][j] == 1:
num_of_land += 1
... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,409 |
s855928469 | p00067 | u811733736 | 1503299188 | Python | Python3 | py | Accepted | 40 | 8064 | 3,047 | # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0067
"""
import sys
import copy
def solve(map):
num_of_land = 0
work = []
lmap = copy.deepcopy(map)
for i, line in enumerate(lmap[1:], start=1):
while 1 in line[1:-1]:
j = line.index(1)
... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,410 |
s569880141 | p00067 | u510797278 | 1504496896 | Python | Python3 | py | Accepted | 30 | 7568 | 804 | import sys
dx = [0, 0, -1, 1]
dy = [1, -1, 0, 0]
def main():
while True:
map = []
count = 0
for i in range(12):
map.append([x for x in input()])
for i in range(12):
for j in range(12):
if map[i][j] == '1':
dfs(map, j, i)... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,411 |
s043558012 | p00067 | u957021183 | 1505109957 | Python | Python3 | py | Accepted | 60 | 7696 | 3,482 | # Aizu Problem 0067: The Number of Islands
#
import sys, math, os
# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
sys.stdin = open("sample-input.txt", "rt")
class UndirectedGraph():
def __init__(self, grid):
offsets = [[0, 1], [0, -1], [1, 0], [-1, 0]]
N = len(grid)
M ... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,412 |
s177125481 | p00067 | u672443148 | 1515308984 | Python | Python3 | py | Accepted | 30 | 5724 | 714 | while True:
c=0
islands=[]
islandsID=[]
ID=0
def dfs(row,col):
global ID
if 0<=row<12 and 0<=col<12:
if islands[row][col]==1 and islandsID[row][col]==0:
islandsID[row][col]=ID
for dr, dc in [[0,1],[1,0],[0,-1],[-1,0]]:
... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,413 |
s738885388 | p00067 | u024715419 | 1518506123 | Python | Python3 | py | Accepted | 20 | 5588 | 907 | def paint(map_inp, x, y):
if map_inp[y][x]:
map_inp[y][x] = False
if map_inp[y][x - 1]:
map_inp = paint(map_inp, x - 1, y)
if map_inp[y][x + 1]:
map_inp = paint(map_inp, x + 1, y)
if map_inp[y - 1][x]:
map_inp = paint(map_inp, x, y - 1)
if ... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,414 |
s200315613 | p00067 | u043254318 | 1518722544 | Python | Python3 | py | Accepted | 20 | 5624 | 1,077 | def get_input():
while True:
try:
yield ''.join(input())
except EOFError:
break
def nuri(table, m, x, y):
if table[x-1][y] and m[x-1][y] == 0:
m[x-1][y] = m[x][y]
nuri(table, m, x-1, y)
if table[x+1][y] and m[x+1][y] == 0:
m[x+1][y] = m[x][y]
... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,415 |
s372930552 | p00067 | u352394527 | 1523336766 | Python | Python3 | py | Accepted | 30 | 5624 | 793 | while True:
lst = []
for i in range(12):
ls = []
s = input()
for j in range(12):
ls.append(int(s[j]))
lst.append(ls)
xd = [0,1,0,-1]
yd = [1,0,-1,0]
count = 0
def check(pt):
if 11 < pt[0] or pt[0] < 0 or 11 < pt[1] or pt[1] < 0:
return False
elif(lst[pt[0]][pt[1]] == 1):
... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,416 |
s113482097 | p00067 | u886729200 | 1523421860 | Python | Python3 | py | Accepted | 20 | 5576 | 1,025 | def counter():#島の数をカウントする
count=0
#12*12個の値をひとつずつ調べる
for x in range(len(is_data)):
for y in range(len(is_data)):
if is_data[x][y] == '1':#島が発見されたら
dfs(x,y)
count+=1
return count
def dfs(x,y):
if x<0 or x == len(is_data) or y<0 or y == len(is_data):... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,417 |
s229977533 | p00067 | u886729200 | 1523422186 | Python | Python3 | py | Accepted | 20 | 5576 | 807 | def counter():#島の数をカウントする
count=0
#12*12個の値をひとつずつ調べる
for x in range(len(is_data)):
for y in range(len(is_data)):
if is_data[x][y] == '1':#島が発見されたら
dfs(x,y)
count+=1
return count
def dfs(x,y):
if x<0 or x == len(is_data) or y<0 or y == len(is_data):... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,418 |
s442033793 | p00067 | u352394527 | 1527543503 | Python | Python3 | py | Accepted | 20 | 5576 | 630 | direct = ((0, -1), (0, 1), (-1, 0), (1, 0)) #移動方向
def search(x, y, mp):
if mp[x][y] == "1": #1を見つけたら0に書き換える
mp[x][y] = "0"
for dx, dy in direct: #4方向について繰り返す
search(x + dx, y + dy, mp)
while True:
#mp...全体のマップ、上下左右を0で囲っておく
mp = [list("0" + input() + "0") for _ in range(12)]
mp.insert(0, [0] * ... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,419 |
s824486759 | p00067 | u847467233 | 1529154700 | Python | Python3 | py | Accepted | 30 | 5608 | 1,045 | # AOJ 0067 The Number of Island
# Python3 2018.6.16 bal4u
# UNION-FIND library
MAX = 12*12
id, size = [0]*MAX, [0]*MAX
def init(n):
for i in range(n): id[i], size[i] = i, 1
def root(i):
while i != id[i]:
id[i] = id[id[i]]
i = id[i]
return i
def connected(p, q):
return root(p) == root(q)
def unite(p, q)... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,420 |
s581847963 | p00067 | u647766105 | 1356471523 | Python | Python | py | Accepted | 20 | 4316 | 454 | def dfs(board,y,x):
if not board[y][x]:
return 0
board[y][x]=0
dx,dy=[0,1,0,-1],[1,0,-1,0]
for i in xrange(4):
dfs(board,y+dy[i],x+dx[i])
return 1
while True:
try:
board=[[0]+map(int,raw_input()[:])+[0] for unused in xrange(12)]
board.insert(13,[0]*14)
boa... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,421 |
s418594836 | p00067 | u542421762 | 1371389522 | Python | Python | py | Accepted | 10 | 4320 | 640 | import sys
def solv(boad):
boad = map(lambda x: [0] + x + [0], boad)
boad.insert(0, [0] * 14)
boad.append([0] * 14)
n = sum([foo(boad, x, y) for x in xrange(1, 13) for y in xrange(1, 13)])
return n
def foo(b, x, y):
if b[y][x]:
b[y][x] = 0
foo(b, x-1, y)
foo(b, x+1, y... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,422 |
s971631115 | p00067 | u782850731 | 1377600472 | Python | Python | py | Accepted | 10 | 4288 | 926 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
unicode_literals)
from sys import stdin
def solve(L):
n = 0
sets = set()
for y in range(12):
for x in range(12):
if not L[y][x]:
conti... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,423 |
s407051546 | p00067 | u560838141 | 1379603561 | Python | Python | py | Accepted | 20 | 4384 | 1,953 |
class UnionFind(object):
def __init__(self, size):
self.data = [-1 for i in range(size)];
def unite(self, x, y):
x = self.root(x);
y = self.root(y);
if (x != y):
if (self.data[y] < self.data[x]):
x, y = y, x;
self.data[x] += self.data... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,424 |
s264103602 | p00067 | u912237403 | 1390096291 | Python | Python | py | Accepted | 20 | 4324 | 905 | import sys
A=range(12)
m=[[0 for i in A] for j in A]
def f(y,x):
f=0
if m[y][x]==1:
m[y][x]=c
f=1
return f
def LR(y,x,dx):
P=[]
x+=dx
while 0<=x<12 and m[y][x]!=0:
if f(y,x):P+=[(y,x)]
x+=dx
return P
def UD(y,x,dy):
P=[]
y+=dy
while 0<=y<12 and m[y... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,425 |
s619797258 | p00067 | u912237403 | 1390097404 | Python | Python | py | Accepted | 20 | 4284 | 703 | import sys
A=range(12)
m=[[0 for i in A] for j in A]
def LRUD(y,x,d):
P=[]
x+=d[0]
y+=d[1]
if 0<=x<12 and 0<=y<12 and m[y][x]==1:
m[y][x]=c
P=[(y,x)]
return P
def v1(buf):
while len(buf)>0:
y,x=buf.pop()
m[y][x]=c
for e in [(-1,0),(1,0),(0,-1),(0,1)]:
... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,426 |
s760017320 | p00067 | u912237403 | 1390098548 | Python | Python | py | Accepted | 20 | 4280 | 598 | import sys
A=range(12)
m=[[0 for i in A] for j in A]
def f(y,x,d):
P=[]
x+=d[0]
y+=d[1]
if 0<=x<12 and 0<=y<12 and m[y][x]==1:
m[y][x]=c
P=[[y,x]]
return P
def v1(buf):
global c
while buf!=[]:
y,x=buf.pop()
m[y][x]=c
for e in [(-1,0),(1,0),(0,-1),(0,1)... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,427 |
s513991938 | p00067 | u912237403 | 1390099807 | Python | Python | py | Accepted | 10 | 4300 | 445 | import sys
A=range(14)
m=[[0 for i in A] for j in A]
def f(y,x):
if m[y][x]==1:
m[y][x]=0
f(y,x+1)
f(y,x-1)
f(y+1,x)
f(y-1,x)
return
def solve():
c=2
for i in A:
while m[i].count(1)>0:
f(i,m[i].index(1))
c+=1
print c-2
retur... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,428 |
s924350196 | p00067 | u912237403 | 1390100678 | Python | Python | py | Accepted | 10 | 4300 | 415 | import sys
A=range(14)
m=[[0 for i in A]for j in A]
def f(y,x):
if m[y][x]==1:
m[y][x]=0
f(y,x+1)
f(y,x-1)
f(y+1,x)
f(y-1,x)
return 1
def solve():
c=0
for i in A:
while m[i].count(1)>0:c+=f(i,m[i].index(1))
print c
return 0
y=0
for s in sys.stdin:
... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,429 |
s689042007 | p00067 | u633068244 | 1394732431 | Python | Python | py | Accepted | 20 | 4336 | 723 | l = 12
def island(f,x,y,m):
rf = f[:][:]
if rf[y][x] == 1:
rf[y][x] = m
for i in [-1,1]:
if 0 <= x+i <= l-1:
rf = island(rf,x+i,y,m)
if 0 <= y+i <= l-1:
rf = island(rf,x,y+i,m)
return rf
while True:
f = []
m = 2
for i in ra... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,430 |
s782303714 | p00067 | u633068244 | 1394733583 | Python | Python | py | Accepted | 20 | 4340 | 692 | def island(f,x,y,m):
rf = f[:][:]
rf[y][x] = m
for i in [-1,1]:
if 0 <= x+i <= 11 and rf[y][x+i] == 1:
rf = island(rf,x+i,y,m)
if 0 <= y+i <= 11 and rf[y+i][x] == 1:
rf = island(rf,x,y+i,m)
return rf
while True:
f = []; m = 2
for i in range(12):
f... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,431 |
s118536302 | p00067 | u260980560 | 1397985042 | Python | Python | py | Accepted | 10 | 4280 | 850 | dx, dy = [-1, 0, 1, 0], [0, -1, 0, 1]
while True:
ans = 0
try:
m = ['0'*14] + ['0'+raw_input()+'0' for i in xrange(12)] + ['0'*14]
f = [[False for i in xrange(14)] for j in xrange(14)]
for y in xrange(1, 13):
for x in xrange(1, 13):
if m[y][x]=='1' and f[y][x]... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,432 |
s373305269 | p00067 | u633068244 | 1399528307 | Python | Python | py | Accepted | 10 | 4292 | 410 | W,H = 12,12
dxy = [[1,0],[0,1],[-1,0],[0,-1]]
def solve(field,w,h):
if 0 <= w < W and 0 <= h < H and field[h][w] == "1":
field[h][w] = "0"
for dx,dy in dxy:
solve(field,w+dx,h+dy)
while 1:
try:
field = [list(raw_input()) for i in range(H)]
ans = 0
for h in range(H):
for w in range(W):
if field[h]... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,433 |
s877356232 | p00067 | u708217907 | 1399817182 | Python | Python | py | Accepted | 10 | 4332 | 631 | def get_map():
map = []
while True:
try:
tmp = list(raw_input())
if len(tmp) != 12: break
map.append(tmp)
except:
break
return map
def remove_island(x, y, map):
map[x][y] = 0
move = [[1, 0], [0, 1], [-1, 0], [0, -1]]
for i, j in move:
if 0 <= x + i <= 11 and 0 <= y + j <... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,434 |
s564769940 | p00067 | u491763171 | 1400481628 | Python | Python | py | Accepted | 10 | 4304 | 605 | H, W = 12, 12
dx = [0, 0, -1, 1]
dy = [-1, 1, 0, 0]
def dfs(i, j):
field[i][j] = 0
for k in xrange(4):
ny = i + dy[k]
nx = j + dx[k]
if nx < 0 or ny < 0 or nx >= W or ny >= H:
continue
if field[ny][nx] == 1:
dfs(ny, nx)
while 1:
field = []
for i... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,435 |
s719853437 | p00067 | u436634575 | 1402302047 | Python | Python3 | py | Accepted | 40 | 6728 | 612 | def count_island(ban):
def remove(x, y):
if 0 <= y < 12 and 0 <= x < 12 and ban[y][x] == 1:
ban[y][x] = 0
for dx, dy in [(-1,0), (1,0), (0,-1), (0,1)]:
remove(x + dx, y + dy)
count = 0
for y in range(12):
for x in range(12):
if ban[y][x] =... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,436 |
s744503109 | p00067 | u803862921 | 1571737663 | Python | Python3 | py | Accepted | 30 | 5616 | 731 |
def dfs(L,i,j):
if L[i][j] > 0:
L[i][j] = 0
else:
return
for k in [-1, 1]:
ni = i + k
if ni not in range(12):
continue
if L[ni][j] > 0:
dfs(L, ni, j)
for k in [-1, 1]:
nj = j + k
if nj not in range(12):
contin... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,437 |
s508537858 | p00067 | u595265835 | 1571320979 | Python | Python3 | py | Accepted | 30 | 5616 | 574 | dx=[1,0,-1,0]
dy=[0,1,0,-1]
def dfs(i,j,m):
m[i][j] = 0
for k in range(4):
x = i + dx[k]
y = j + dy[k]
if (x < 12 and x >= 0 and y < 12 and y >= 0 and m[x][y] == 1):
dfs(x,y,m)
return
while True:
try:
m = []
sum = 0
for i in range(12):
... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,438 |
s515573817 | p00067 | u548252256 | 1564160551 | Python | Python3 | py | Accepted | 20 | 5576 | 505 |
def dfs(A,x,y):
X = [1,0,-1,0]
Y = [0,1,0,-1]
A[x][y] = 0
for i in range(4):
xx = x + X[i]
yy = y + Y[i]
if 0 <= xx < 12 and 0 <= yy < 12:
if A[xx][yy] == "1":
dfs(A,xx,yy)
if __name__ == '__main__':
A = []
while True:
try:
for _ in range(12):
ll = list(input())
A.append(ll)
... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,439 |
s498501577 | p00067 | u406093358 | 1555554094 | Python | Python | py | Accepted | 10 | 4692 | 903 | import sys
dataset = []
lst = []
for line in sys.stdin:
lst.append(line)
minilist = []
for i in range(0, len(lst)):
if lst[i] == '\n':
dataset.append(minilist)
minilist = []
else: minilist.append(lst[i])
dataset.append(minilist)
for i in range(0, len(dataset)):
memo = []
for j in range(0, 12):
lst = []
fo... | p00067 |
<H1>島の数</H1>
<p>
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。
</p>
<pre>
■■■■□□□□■■■■
■■■□□□□□■■■■
■■□□□□□□■■■■
■□□□□□□□■■■■
□□□■□□□■□□□□
□□□□□□■■■□□□
□□□□□■■■■■□□
■□□□■■■■■■■□
■■□□□■■■■■... | 111100001111
111000001111
110000001111
100000001111
000100010000
000000111000
000001111100
100011111110
110001111100
111000111000
111100010000
000000000000
010001111100
110010000010
010010000001
010000000001
010000000110
010000111000
010000000100
010000000010
010000000001
010010000001
010010000010
111001111100
000000... | 5
13
4
| 11,440 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.