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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s086786487 | p02244 | u921537862 | 1582940529 | Python | Python3 | py | Accepted | 90 | 6356 | 1,327 | def main():
from copy import deepcopy
from itertools import permutations
import sys
input=sys.stdin.readline
k=int(input())
stage=[[0]*8 for _ in range(8)]
ans=[['.']*8 for _ in range(8)]
ablex=[0,1,2,3,4,5,6,7]
abley=[0,1,2,3,4,5,6,7]
def q(x,y,stage):
i,j=x,y
... | p02244 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
<H1>8 Queens Problem</H1>
<p>... | 2
2 2
5 3
| ......Q.
Q.......
..Q.....
.......Q
.....Q..
...Q....
.Q......
....Q...
| 30,182 |
s721145469 | p02244 | u247112781 | 1582530333 | Python | Python3 | py | Accepted | 40 | 5824 | 1,390 | # 8 Queens Problem
import sys, itertools
input = sys.stdin.buffer.readline
sys.setrecursionlimit(1000000000)
board = [["."]*8 for _ in range(8)]
def diagonal_positions(Q):
output = set()
output.add(Q)
for i in range(8):
output.add((Q[0] + i, Q[1] + i))
output.add((Q[0] + i, Q[1] - i))
... | p02244 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
<H1>8 Queens Problem</H1>
<p>... | 2
2 2
5 3
| ......Q.
Q.......
..Q.....
.......Q
.....Q..
...Q....
.Q......
....Q...
| 30,183 |
s308345505 | p02244 | u870370075 | 1582468645 | Python | Python3 | py | Accepted | 60 | 5656 | 804 | import itertools
def judge(board):
ret=True
pos=[]
for i in range(8):
for j in range(8):
if board[i][j]=='Q':
pos.append((i,j))
for i in range(8):
tx1,ty1=pos[i]
for j in range(8):
tx2,ty2=pos[j]
if i==j:
continue
if ty1==ty2 or tx1==tx2 or abs(ty1-ty2)==abs(... | p02244 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
<H1>8 Queens Problem</H1>
<p>... | 2
2 2
5 3
| ......Q.
Q.......
..Q.....
.......Q
.....Q..
...Q....
.Q......
....Q...
| 30,184 |
s734266237 | p02244 | u037175009 | 1582445058 | Python | Python3 | py | Accepted | 50 | 6324 | 823 | import sys
import itertools
import copy
input = sys.stdin.readline
n = int(input())
q = [tuple(map(int,input().split())) for _ in range(n)]
px = [0,1,2,3,4,5,6,7]
py = [0,1,2,3,4,5,6,7]
for i in q:
px.remove(i[0])
py.remove(i[1])
for v in itertools.permutations(py):
r_q = copy.deepcopy(q)
for x,y in ... | p02244 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
<H1>8 Queens Problem</H1>
<p>... | 2
2 2
5 3
| ......Q.
Q.......
..Q.....
.......Q
.....Q..
...Q....
.Q......
....Q...
| 30,185 |
s424932055 | p02244 | u369455271 | 1580368828 | Python | Python3 | py | Accepted | 20 | 5620 | 1,156 | class Field:
def __init__(self, N):
self.N = N
self.row = [-1 for _ in range(N)]
self.hold = []
self.col = [0 for _ in range(N)]
self.dpos = [0 for _ in range(2*N - 1)]
self.dneg = [0 for _ in range(2*N - 1)]
def putQueen(self, i):
if i in self.hold:
... | p02244 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
<H1>8 Queens Problem</H1>
<p>... | 2
2 2
5 3
| ......Q.
Q.......
..Q.....
.......Q
.....Q..
...Q....
.Q......
....Q...
| 30,186 |
s130668267 | p02244 | u529459816 | 1577602851 | Python | Python3 | py | Accepted | 30 | 6024 | 2,306 | from collections import deque
def nqueen(queen_rcs, n, k):
def rc2idx(r, c): # 7,7->88となる
return (n + 2) * (r + 1) + c + 1
queens = deque([])
table = [None] * (n + 2) + ([None] + [-1] * n + [None]) * n + [None] * (n + 2)
directions = [-(n + 3), -(n + 2), -(n + 1), -1, 1, n + 1, n + 2, n + 3]
... | p02244 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
<H1>8 Queens Problem</H1>
<p>... | 2
2 2
5 3
| ......Q.
Q.......
..Q.....
.......Q
.....Q..
...Q....
.Q......
....Q...
| 30,187 |
s444156058 | p02244 | u794140916 | 1576805757 | Python | Python3 | py | Accepted | 30 | 5620 | 1,221 |
N = 8
FREE = -1
NOT_FREE = 1
def printBoard():
for i in range(N):
for j in range(N):
if X[i][j]:
if not Y[i][j]:
return
for i in range(N):
for j in range(N):
if Y[i][j]:
print("Q", end = "")
else:
... | p02244 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
<H1>8 Queens Problem</H1>
<p>... | 2
2 2
5 3
| ......Q.
Q.......
..Q.....
.......Q
.....Q..
...Q....
.Q......
....Q...
| 30,188 |
s356050980 | p02244 | u957523223 | 1575707212 | Python | Python3 | py | Accepted | 20 | 5612 | 999 | def printBorad():
for i in range(8):
s = ['.'] * 8
s[row[i]] = 'Q'
print(''.join(s))
def putQueen(i, j):
row[i] = j
col[j] = True
left[i+j] = True
right[7+i-j] = True
def removeQueen(i, j):
row[i] = False
col[j] = False
left[i+j] = False
right[7+i-j] = False... | p02244 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
<H1>8 Queens Problem</H1>
<p>... | 2
2 2
5 3
| ......Q.
Q.......
..Q.....
.......Q
.....Q..
...Q....
.Q......
....Q...
| 30,189 |
s908124908 | p02244 | u638043175 | 1575423450 | Python | Python3 | py | Accepted | 20 | 5692 | 1,239 | import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30
col = []
row = []
rd = []
lu = []
board = [['.'] * 8 for _ in range(8)]
def put(r, c):
global col, row, rd, lu, board
col.append(c)
row.append(r)
rd.append(c-r)
lu.append(r+c)
boar... | p02244 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
<H1>8 Queens Problem</H1>
<p>... | 2
2 2
5 3
| ......Q.
Q.......
..Q.....
.......Q
.....Q..
...Q....
.Q......
....Q...
| 30,190 |
s061734626 | p02244 | u165578704 | 1574754993 | Python | Python3 | py | Accepted | 70 | 5644 | 1,742 | # -*- coding: utf-8 -*-
import sys
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, ... | p02244 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
<H1>8 Queens Problem</H1>
<p>... | 2
2 2
5 3
| ......Q.
Q.......
..Q.....
.......Q
.....Q..
...Q....
.Q......
....Q...
| 30,191 |
s404567997 | p02244 | u487861672 | 1568724104 | Python | Python3 | py | Accepted | 30 | 6048 | 1,454 | from collections import namedtuple
State = namedtuple("State", "queen row col dpos dneg")
def put_queen(s, r, c):
s.queen[r] = c
s.row[r] = s.col[c] = s.dpos[r + c] = s.dneg[r - c + 8 - 1] = True
def unput_queen(s, r, c):
s.queen[r] = None
s.row[r] = s.col[c] = s.dpos[r + c] = s.dneg[r - c + 8 - 1]... | p02244 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
<H1>8 Queens Problem</H1>
<p>... | 2
2 2
5 3
| ......Q.
Q.......
..Q.....
.......Q
.....Q..
...Q....
.Q......
....Q...
| 30,192 |
s916212882 | p02244 | u902579831 | 1561801780 | Python | Python3 | py | Accepted | 40 | 5620 | 1,102 | N = 8
FREE = 1
NOT_FREE = -1
row = [FREE] * N
col = [FREE] * N
dpos = [FREE] * (2 * N - 1)
dneg = [FREE] * (2 * N - 1)
board = [[False] * N for _ in range(N)]
k = int(input())
for _ in range(k):
r, c = map(int, input().split())
board[r][c] = True
def slove(i):
if i == N:
print_board()
... | p02244 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
<H1>8 Queens Problem</H1>
<p>... | 2
2 2
5 3
| ......Q.
Q.......
..Q.....
.......Q
.....Q..
...Q....
.Q......
....Q...
| 30,193 |
s080461325 | p02244 | u495152850 | 1561738158 | Python | Python3 | py | Accepted | 20 | 5620 | 958 | NOT_FREE = 1
FREE = 0
q = [0 for i in range(8)]
row = [0 for i in range(8)]
col = [0 for i in range(8)]
dneg = [0 for i in range (16)]
dpos = [0 for i in range (16)]
def printBord():
for r in range(8):
for c in range(8):
if q[r] == c:
print("Q",end="")
else: pri... | p02244 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
<H1>8 Queens Problem</H1>
<p>... | 2
2 2
5 3
| ......Q.
Q.......
..Q.....
.......Q
.....Q..
...Q....
.Q......
....Q...
| 30,194 |
s382923372 | p02244 | u488231174 | 1558321502 | Python | Python3 | py | Accepted | 20 | 5620 | 645 | k = int(input())
row = [1] * 8
col = [1] * 8
dpos = [1] * 15
dneg = [1] * 15
X = [['.' for j in range(8)] for i in range(8)]
for i in range(k):
r, c = map(int, input().split())
row[r] = col[c] = dpos[r+c] = dneg[r-c+7] = 0
X[r][c] = 'Q'
def s(i):
while i < 8 and not row[i]:i += 1
if i == 8... | p02244 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
<H1>8 Queens Problem</H1>
<p>... | 2
2 2
5 3
| ......Q.
Q.......
..Q.....
.......Q
.....Q..
...Q....
.Q......
....Q...
| 30,195 |
s710236351 | p02244 | u686180487 | 1558308714 | Python | Python3 | py | Accepted | 30 | 5624 | 933 | # -*- coding: utf-8 -*-
N = 8
row = [-1 for i in range(N)]
col = [False for i in range(N)]
board = [[False for i in range(N)] for j in range(N)]
pos = [False for i in range(2*N-1)]
neg = [False for i in range(2*N-1)]
num = int(input())
for i in range(num):
x, y = list(map(int, input().split()))
board[x][y] = Tr... | p02244 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
<H1>8 Queens Problem</H1>
<p>... | 2
2 2
5 3
| ......Q.
Q.......
..Q.....
.......Q
.....Q..
...Q....
.Q......
....Q...
| 30,196 |
s610710516 | p02244 | u890713354 | 1558282168 | Python | Python3 | py | Accepted | 20 | 5620 | 1,900 | answer_printed = 0
answer=[]
for i in range(8):
answer.append([])
for i in range(8):
for j in range(8):
answer[i].append('.')
row=[]
for i in range(8):
row.append('.')
col=[]
for i in range(8):
col.append('.')
right_slope=[]
for i in range(15):
right_slope.append('.')
left_slope=[]
for i in ... | p02244 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
<H1>8 Queens Problem</H1>
<p>... | 2
2 2
5 3
| ......Q.
Q.......
..Q.....
.......Q
.....Q..
...Q....
.Q......
....Q...
| 30,197 |
s125688526 | p02244 | u241923784 | 1557995515 | Python | Python3 | py | Accepted | 20 | 5620 | 952 | NOT_FREE = 1
FREE = 0
q = [0 for i in range(8)]
row = [0 for i in range(8)]
col = [0 for i in range(8)]
dneg = [0 for i in range (16)]
dpos = [0 for i in range (16)]
def printBord():
for r in range(8):
for c in range(8):
if q[r] == c:
print("Q",end="")
else: print(... | p02244 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
<H1>8 Queens Problem</H1>
<p>... | 2
2 2
5 3
| ......Q.
Q.......
..Q.....
.......Q
.....Q..
...Q....
.Q......
....Q...
| 30,198 |
s932383299 | p02244 | u568418629 | 1557927166 | Python | Python3 | py | Accepted | 20 | 5624 | 1,073 | import sys
N = 8
row = [-1] * N
col = [0] * N
dpos = [0] * (N*2-1)
dneg = [0] * (N*2-1)
def print_board():
for i in range(N):
for j in range(N):
if row[i] == j:
print("Q", end='')
else:
print(".", end='')
print("\n", end='')
def put_queen(... | p02244 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
<H1>8 Queens Problem</H1>
<p>... | 2
2 2
5 3
| ......Q.
Q.......
..Q.....
.......Q
.....Q..
...Q....
.Q......
....Q...
| 30,199 |
s050803472 | p02244 | u464454066 | 1557727993 | Python | Python3 | py | Accepted | 20 | 5644 | 1,368 | import sys
import time
input = sys.stdin.readline
FREE = True
NOT_FREE = False
num = int(input())
Q = [list(map(int, input().split())) for i in range(num)]
row = [FREE]*8
col = [FREE]*8
dpos = [FREE]*15
dneg = [FREE]*15
chess_board = [['.' for i in range(8)] for j in range(8)]
def printBoard():
for c in chess_bo... | p02244 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
<H1>8 Queens Problem</H1>
<p>... | 2
2 2
5 3
| ......Q.
Q.......
..Q.....
.......Q
.....Q..
...Q....
.Q......
....Q...
| 30,200 |
s073536028 | p02244 | u805716376 | 1557043272 | Python | Python3 | py | Accepted | 30 | 5616 | 981 | N = int(input())
a = []
b = []
c = []
for i in range(N):
a += [list(map(int, input().split()))]
row = [1]*9
col = [1]*9
dops = [1]*16
dneg = [1]*16
def sett(x, y):
row[y] = 0
col[x] = 0
dops[x+y] = 0
dneg[y-x+7] = 0
def dsett(x, y):
row[y] = 1
col[x] = 1
dops[x+y] = 1
dneg[y-x... | p02244 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
<H1>8 Queens Problem</H1>
<p>... | 2
2 2
5 3
| ......Q.
Q.......
..Q.....
.......Q
.....Q..
...Q....
.Q......
....Q...
| 30,201 |
s966619003 | p02244 | u798796508 | 1548917265 | Python | Python3 | py | Accepted | 20 | 5644 | 1,763 | def sakuzyo(i):
if koteirow[i] == 1:
sakuzyo(i-1)
else:
for j in range(N):
if haiti[i][j] == 'Q':
#print('delete {} {}'.format(i, j))
haiti[i][j] = '.'
row[i] = 0
col[j] = 0
dpos[i + j] = 0
... | p02244 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
<H1>8 Queens Problem</H1>
<p>... | 2
2 2
5 3
| ......Q.
Q.......
..Q.....
.......Q
.....Q..
...Q....
.Q......
....Q...
| 30,202 |
s821415557 | p02244 | u803657704 | 1548891419 | Python | Python3 | py | Accepted | 20 | 5620 | 979 | N = 8
tate = [True]*N
yoko = [True]*N
rnaname = [True]*(2*N-1)
lnaname = [True]*(2*N-1)
board = [[True]*N for i in range(N)]
def update(x, y, value):
tate[x] = value
yoko[y] = value
rnaname[x+y] = value
lnaname[x-y+N-1] = value
board[x][y] = value
def check(x, y):
if tate[x] and yoko[y] and ... | p02244 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
<H1>8 Queens Problem</H1>
<p>... | 2
2 2
5 3
| ......Q.
Q.......
..Q.....
.......Q
.....Q..
...Q....
.Q......
....Q...
| 30,203 |
s784026074 | p02244 | u072053884 | 1545198906 | Python | Python3 | py | Accepted | 20 | 5616 | 959 | row = [False] * 8
col = [False] * 8
dpos = [False] * 15
dneg = [False] * 15
board = [['.', '.', '.', '.', '.', '.', '.', '.'] for i in range(8)]
import sys
file_input = sys.stdin
k = int(file_input.readline())
for line in file_input:
r, c = map(int, line.split())
row[r] = True
col[c] = True
dpos[r... | p02244 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
<H1>8 Queens Problem</H1>
<p>... | 2
2 2
5 3
| ......Q.
Q.......
..Q.....
.......Q
.....Q..
...Q....
.Q......
....Q...
| 30,204 |
s744175736 | p02244 | u800534567 | 1545178079 | Python | Python3 | py | Accepted | 40 | 5624 | 1,084 | import sys
blank = [i for i in range(64)]
nump = int(sys.stdin.readline())
qpos = []
for _ in range(nump):
j, i = map(int, sys.stdin.readline().split())
qpos.append([j*8+i, j-i, j+i])
for x in range(8):
if j*8+x in blank: blank.remove(j*8+x)
if x*8+i in blank: blank.remove(x*8+i)
if... | p02244 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
<H1>8 Queens Problem</H1>
<p>... | 2
2 2
5 3
| ......Q.
Q.......
..Q.....
.......Q
.....Q..
...Q....
.Q......
....Q...
| 30,205 |
s023763548 | p02244 | u125481461 | 1542596629 | Python | Python3 | py | Accepted | 20 | 5612 | 1,652 | vert = [False] * 8
hori = [False] * 8
topright = [False] * (8 * 2 - 1)
topleft = [False] * (8 * 2 - 1)
queens = []
skip_row = []
def put_queen(x, y):
vert[x] = True
hori[y] = True
topright[x + y] = True
topleft[7 + (x - y)] = True
queens.append((x, y))
def elim_queen(x, y):
vert[x] = False
... | p02244 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
<H1>8 Queens Problem</H1>
<p>... | 2
2 2
5 3
| ......Q.
Q.......
..Q.....
.......Q
.....Q..
...Q....
.Q......
....Q...
| 30,206 |
s787634752 | p02244 | u260980560 | 1539395570 | Python | Python3 | py | Accepted | 30 | 5672 | 634 | from itertools import permutations
N = 8
M = [['.']*N for i in range(N)]
A0 = set()
B0 = set()
K = int(input())
R = set(range(N))
C = set(range(N))
for i in range(K):
r, c = map(int, input().split())
R.remove(r); C.remove(c)
M[r][c] = 'Q'
A0.add(r+c)
B0.add(r-c)
for CS in permutations(C):
A... | p02244 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
<H1>8 Queens Problem</H1>
<p>... | 2
2 2
5 3
| ......Q.
Q.......
..Q.....
.......Q
.....Q..
...Q....
.Q......
....Q...
| 30,207 |
s965844396 | p02244 | u629780968 | 1538121615 | Python | Python3 | py | Accepted | 20 | 5620 | 633 | board = [["." for i in range(8)] for i in range(8)]
N = int(input())
row = [1] * 8
col = [1] * 8
dpos = [1] * 15
dneg = [1] * 15
for i in range(N):
x, y = map(int, input().split())
row[x] = col[y] = dpos[x+y] =dneg[x-y+7] = 0
board[x][y] = "Q"
def solve(i):
while i < 8 and not row[i]:
i += 1
if i == 8:... | p02244 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
<H1>8 Queens Problem</H1>
<p>... | 2
2 2
5 3
| ......Q.
Q.......
..Q.....
.......Q
.....Q..
...Q....
.Q......
....Q...
| 30,208 |
s777292950 | p02244 | u665238221 | 1536140953 | Python | Python3 | py | Accepted | 30 | 5668 | 727 | from itertools import permutations
def check(queen):
for r1, c1 in queen:
if not all((r1 == r2 and c1 == c2) or (r1 + c1 != r2 + c2 and r1 - c1 != r2 - c2)
for r2, c2 in queen):
return False
return True
N = int(input())
row, col = list(range(8)), list(range(8))
queen =... | p02244 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
<H1>8 Queens Problem</H1>
<p>... | 2
2 2
5 3
| ......Q.
Q.......
..Q.....
.......Q
.....Q..
...Q....
.Q......
....Q...
| 30,209 |
s064011261 | p02244 | u424720817 | 1532665597 | Python | Python3 | py | Accepted | 20 | 5624 | 1,385 | import sys
N = 8
board = [[0 for j in range(N)] for i in range(N)]
queen = [-1] * N
def main():
init()
search(0)
def search(i):
if i == N:
printBoard()
sys.exit()
if queen[i] != -1:
search(i + 1)
else :
for j in range(N):
if board[i][j] == 0:
... | p02244 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
<H1>8 Queens Problem</H1>
<p>... | 2
2 2
5 3
| ......Q.
Q.......
..Q.....
.......Q
.....Q..
...Q....
.Q......
....Q...
| 30,210 |
s436814189 | p02244 | u079141094 | 1471238917 | Python | Python3 | py | Accepted | 30 | 7848 | 1,614 | # Heuristic Search - 8 Queens Problem
def reload_board(B,r,c,diff):
# ?????¨???????????????????????????????????????????????????????????????????????????????????°????????????
global Q,NUM
for i in range(NUM):
# ????¨???????????????¶???
B[r][i] += diff
B[i][c] += diff
# ????§?45... | p02244 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
<H1>8 Queens Problem</H1>
<p>... | 2
2 2
5 3
| ......Q.
Q.......
..Q.....
.......Q
.....Q..
...Q....
.Q......
....Q...
| 30,211 |
s945018564 | p02245 | u426534722 | 1500307235 | Python | Python3 | py | Accepted | 100 | 12804 | 1,115 | from sys import stdin
from heapq import heappop, heappush
FORE = 1
BACK = 0
adjacent = ((1,3), (0,2,4), (1,5), (0,4,6), (1,3,5,7), (2,4,8), (3,7), (4,6,8), (5,7))
start = [int(a) for _ in range(3) for a in stdin.readline().split()]
end = [1, 2, 3, 4, 5, 6, 7, 8, 0]
def next_board(board, space, prev):
for nxt in adj... | p02245 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
<H1>8 Puzzle</H1>
<p>
The g... | 1 3 0
4 2 5
7 8 6
| 4
| 30,212 |
s480327836 | p02245 | u072053884 | 1507569408 | Python | Python3 | py | Accepted | 60 | 13476 | 1,184 | adjacent = (
(1, 3), # 0
(0, 2, 4), # 1
(1, 5), # 2
(0, 4, 6), # 3
(1, 3, 5, 7), # 4
(2, 4, 8), # 5
(3, 7), # 6
(4, 6, 8), # 7
(5, 7) # 8
)
import collections
GOAL = [1, 2, 3, 4, 5, 6, 7, 8, 0]
# Bidirectional search using breadth-first search
... | p02245 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
<H1>8 Puzzle</H1>
<p>
The g... | 1 3 0
4 2 5
7 8 6
| 4
| 30,213 |
s148463526 | p02245 | u072053884 | 1507569694 | Python | Python3 | py | Accepted | 70 | 13080 | 1,164 | adjacent = (
(1, 3), # 0
(0, 2, 4), # 1
(1, 5), # 2
(0, 4, 6), # 3
(1, 3, 5, 7), # 4
(2, 4, 8), # 5
(3, 7), # 6
(4, 6, 8), # 7
(5, 7) # 8
)
GOAL = [1, 2, 3, 4, 5, 6, 7, 8, 0]
# Bidirectional search using breadth-first search
def solve(start):
... | p02245 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
<H1>8 Puzzle</H1>
<p>
The g... | 1 3 0
4 2 5
7 8 6
| 4
| 30,214 |
s235376474 | p02245 | u072053884 | 1507570032 | Python | Python3 | py | Accepted | 50 | 13220 | 1,164 | adjacent = (
(1, 3), # 0
(0, 2, 4), # 1
(1, 5), # 2
(0, 4, 6), # 3
(1, 3, 5, 7), # 4
(2, 4, 8), # 5
(3, 7), # 6
(4, 6, 8), # 7
(5, 7) # 8
)
GOAL = [1, 2, 3, 4, 5, 6, 7, 8, 0]
# Bidirectional search using breadth-first search
def solve(start):
... | p02245 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
<H1>8 Puzzle</H1>
<p>
The g... | 1 3 0
4 2 5
7 8 6
| 4
| 30,215 |
s234078733 | p02245 | u426534722 | 1519827644 | Python | Python3 | py | Accepted | 60 | 8884 | 891 | from collections import deque
N = 3
def g(i, j, a):
if i > j:
i, j = j, i
return a[:i] + a[j] + a[i + 1:j] + a[i] + a[j + 1:]
goal = "123456780"
def solve():
m = {8:{7, 5}, 7:{8, 6, 4}, 6:{7, 3}, 5:{8, 4, 2}, 4:{7, 5, 3, 1}, 3:{6, 4, 0}, 2:{5, 1}, 1:{4, 2, 0}, 0:{3, 1}}
MAP = "".join(input().rep... | p02245 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
<H1>8 Puzzle</H1>
<p>
The g... | 1 3 0
4 2 5
7 8 6
| 4
| 30,216 |
s539625921 | p02245 | u426534722 | 1519828008 | Python | Python3 | py | Accepted | 60 | 8884 | 905 | from collections import deque
N = 3
goal = "123456780"
def g(i, j, a):
if i > j:
i, j = j, i
return a[:i] + a[j] + a[i + 1:j] + a[i] + a[j + 1:]
def solve():
m = {8:{7, 5}, 7:{8, 6, 4}, 6:{7, 3}, 5:{8, 4, 2}, 4:{7, 5, 3, 1}, 3:{6, 4, 0}, 2:{5, 1}, 1:{4, 2, 0}, 0:{3, 1}}
start = "".join(input().r... | p02245 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
<H1>8 Puzzle</H1>
<p>
The g... | 1 3 0
4 2 5
7 8 6
| 4
| 30,217 |
s694650984 | p02245 | u426534722 | 1519830439 | Python | Python3 | py | Accepted | 50 | 8488 | 919 | from collections import deque
N = 3
m = {8: {7, 5}, 7: {8, 6, 4}, 6: {7, 3}, 5: {8, 4, 2}, 4: {7, 5, 3, 1}, 3: {6, 4, 0}, 2: {5, 1}, 1: {4, 2, 0},
0: {3, 1}}
goal = 123456780
def g(i, j, a):
t = a // (10 ** j) % 10
return a - t * (10 ** j) + t * (10 ** i)
def solve():
MAP = "".join(input().replace(" ",... | p02245 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
<H1>8 Puzzle</H1>
<p>
The g... | 1 3 0
4 2 5
7 8 6
| 4
| 30,218 |
s057596078 | p02245 | u466299927 | 1524469728 | Python | Python3 | py | Accepted | 60 | 10652 | 4,482 | # -*- coding: utf-8 -*-
import sys
from itertools import chain
def get_completed_board(height, width):
return [str((i + 1) % (width * height)) for i in range(width * height)]
def serialize_board(board):
return ":".join(board)
def get_empty_pos(board, width, height):
for i, cell in enumerate(board):
... | p02245 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
<H1>8 Puzzle</H1>
<p>
The g... | 1 3 0
4 2 5
7 8 6
| 4
| 30,219 |
s301123009 | p02245 | u488231174 | 1558322200 | Python | Python3 | py | Accepted | 50 | 10684 | 1,170 | adjacent = (
(1, 3), # 0
(0, 2, 4), # 1
(1, 5), # 2
(0, 4, 6), # 3
(1, 3, 5, 7), # 4
(2, 4, 8), # 5
(3, 7), # 6
(4, 6, 8), # 7
(5, 7) # 8
)
GOAL = [1, 2, 3, 4, 5, 6, 7, 8, 0]
# Bidirectional search using breadth-first search
def solve(start):
... | p02245 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML">
</script>
<H1>8 Puzzle</H1>
<p>
The g... | 1 3 0
4 2 5
7 8 6
| 4
| 30,220 |
s105251890 | p02247 | u318430977 | 1531926189 | Python | Python3 | py | Accepted | 20 | 5572 | 294 | t = input()
p = input()
for i in range(len(t)):
for j in range(len(p) + 1):
if j == len(p):
print(i)
else:
if i + j >= len(t):
break
elif t[i + j] == p[j]:
continue
else:
break
| p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,221 |
s752793706 | p02247 | u279605379 | 1535353800 | Python | Python3 | py | Accepted | 20 | 5568 | 100 | T = input()
P = input()
p = len(P)
for i in range(len(T)-p+1):
if T[i:i+p]==P:
print(i)
| p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,222 |
s902030931 | p02247 | u726330006 | 1540797103 | Python | Python3 | py | Accepted | 20 | 5592 | 1,013 | text=input()
string=input()
#common_length[i]は、探索列がstring[i]で探索を終了したときに、
# string[i-common_lneght[i] + 1] 〜string[i]で構成される文字列が、探索価値を持つことを示す
len_string=len(string)
common_length=[0]*len_string
tmp=0
for i in range(1,len_string):
if(string[i]==string[tmp]):
if(string[i-1]==string[tmp-1]):
comm... | p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,223 |
s579949852 | p02247 | u726330006 | 1540798002 | Python | Python3 | py | Accepted | 20 | 5588 | 1,022 | text=input()
string=input()
#common_length[i]は、探索列がstring[i]で探索を終了したときに、
# string[i-common_lneght[i] + 1] 〜string[i]で構成される文字列が、探索価値を持つことを示す
len_string=len(string)
common_length=[0]*len_string
tmp=0
for i in range(1,len_string):
if(string[i]==string[tmp]):
if(string[i-1]==string[max([tmp-1,0])]):
... | p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,224 |
s188002437 | p02247 | u726330006 | 1540799215 | Python | Python3 | py | Accepted | 20 | 5584 | 1,013 | text=input()
string=input()
#common_length[i]は、探索列がstring[i]で探索を終了したときに、
# string[i-common_lneght[i] + 1] 〜string[i]で構成される文字列が、探索価値を持つことを示す
len_string=len(string)
common_length=[0]*len_string
tmp=0
for i in range(1,len_string):
if(string[i]==string[tmp]):
if(string[i-1]==string[tmp-1]):
comm... | p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,225 |
s910922897 | p02247 | u726330006 | 1540799274 | Python | Python3 | py | Accepted | 20 | 5584 | 1,013 | text=input()
string=input()
#common_length[i]は、探索列がstring[i]で探索を終了したときに、
# string[i-common_lneght[i] + 1] 〜string[i]で構成される文字列が、探索価値を持つことを示す
len_string=len(string)
common_length=[0]*len_string
tmp=0
for i in range(1,len_string):
if(string[i]==string[tmp]):
if(string[i-1]==string[tmp-1]):
comm... | p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,226 |
s672759843 | p02247 | u726330006 | 1540807235 | Python | Python3 | py | Accepted | 20 | 5588 | 1,069 | text=input()
string=input()
#common_length[i]は、探索列がstring[i]で探索を終了したときに、
# string[i-common_lneght[i] + 1] 〜string[i]で構成される文字列が、探索価値を持つことを示す
len_string=len(string)
common_length=[0]*len_string
tmp=0
tmp_tmp=0
for i in range(1,len_string):
if(string[i]==string[tmp]):
tmp_tmp=tmp
while(string[i]==s... | p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,227 |
s015451570 | p02247 | u726330006 | 1540808878 | Python | Python3 | py | Accepted | 20 | 5584 | 1,080 | text=input()
string=input()
#common_length[i]は、探索列がstring[i]で探索を終了したときに、
# string[i-common_lneght[i] + 1] 〜string[i]で構成される文字列が、探索価値を持つことを示す
len_string=len(string)
common_length=[0]*len_string
tmp=0
tmp_tmp=0
for i in range(1,len_string):
if(string[i]==string[tmp]):
tmp_tmp=tmp
while(string[i]==s... | p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,228 |
s524523327 | p02247 | u799595944 | 1556357697 | Python | Python3 | py | Accepted | 20 | 5572 | 282 | t = list(input())
p = list(input())
n = len(t) - len(p) + 1
for i in range(n):
if p[0] == t[i]:
for j in range(len(p)):
flag = True
if not p[j] == t[i+j]:
flag = False
break
if flag:
print(i)
| p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,229 |
s936347435 | p02247 | u797673668 | 1455095863 | Python | Python3 | py | Accepted | 30 | 7488 | 119 | t, p = input(), input()
len_p = len(p)
for i in range(len(t) - len_p + 1):
if t[i:i + len_p] == p:
print(i) | p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,230 |
s414981740 | p02247 | u408260374 | 1455882159 | Python | Python3 | py | Accepted | 50 | 7484 | 92 | T, P = input(), input()
for i in range(len(T)):
if T[i:].startswith(P):
print(i) | p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,231 |
s164637558 | p02247 | u731710433 | 1457509493 | Python | Python3 | py | Accepted | 20 | 7476 | 106 | t, p = input(), input()
for i in range(len(t) - len(p) + 1):
if t[i:i + len(p)] == p:
print(i) | p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,232 |
s463488973 | p02247 | u320446607 | 1460353089 | Python | Python3 | py | Accepted | 40 | 7484 | 83 | T, P = input(), input()
for i in range(len(T)):
if T[i:].startswith(P):
print(i) | p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,233 |
s206903644 | p02247 | u811733736 | 1480571338 | Python | Python3 | py | Accepted | 20 | 7460 | 341 | if __name__ == '__main__':
# ??????????????\???
# T = 'abc'
# P = 'xyz'
T = input()
P = input()
# ???????????????
results = []
for i in range(len(T) - len(P) + 1):
temp = T[i:i+len(P)]
if temp == P:
results.append(i)
# ???????????¨???
for r in resul... | p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,234 |
s670210640 | p02247 | u159356473 | 1481606724 | Python | Python3 | py | Accepted | 30 | 7524 | 482 | #coding:utf-8
def NSS(s1,s2):
s1list=list(s1)
n=len(s1list)
s2list=list(s2)
for i in range(n):
ans=0
if len(s1list)>=len(s2list) and s1list[0]==s2list[0]:
ans+=1
for j in range(1,len(s2list)):
if s1list[j]==s2list[j]:
ans+=1
... | p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,235 |
s201773357 | p02247 | u022407960 | 1482090324 | Python | Python3 | py | Accepted | 20 | 7536 | 750 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
input:
aabaaa
aa
output:
0
3
4
"""
import sys
class NaiveStringSearch(object):
__slots__ = ('target', 'pattern')
def __init__(self, in_data):
""""""
self.target = in_data[0].strip()
self.pattern = in_data[1].strip()
def naive_m... | p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,236 |
s432826638 | p02247 | u022407960 | 1482159928 | Python | Python3 | py | Accepted | 30 | 7544 | 730 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
input:
aabaaa
aa
output:
0
3
4
"""
import sys
class NaiveStringSearch(object):
__slots__ = ('target', 'pattern')
def __init__(self, in_data):
""""""
self.target, self.pattern = map(lambda x: x.strip(), _input)
def brute_force(self):
... | p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,237 |
s297123105 | p02247 | u022407960 | 1482159962 | Python | Python3 | py | Accepted | 30 | 7536 | 730 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
input:
aabaaa
aa
output:
0
3
4
"""
import sys
class NaiveStringSearch(object):
__slots__ = ('target', 'pattern')
def __init__(self, in_data):
""""""
self.target, self.pattern = map(lambda x: x.strip(), _input)
def brute_force(self):
... | p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,238 |
s347978286 | p02247 | u078042885 | 1486709743 | Python | Python3 | py | Accepted | 30 | 7380 | 74 | t=input();p=input()
[print(i)for i in range(len(t))if t[i:].startswith(p)] | p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,239 |
s192100535 | p02247 | u910697883 | 1486711456 | Python | Python3 | py | Accepted | 20 | 7408 | 240 | string = input()
teststring = input()
length = len(teststring)
counter = []
for position in range(0, len(string)):
if string[position:position + length] == teststring:
counter.append(position)
for content in counter:
print(content) | p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,240 |
s405745842 | p02247 | u831244171 | 1487523999 | Python | Python3 | py | Accepted | 30 | 7480 | 262 | T = list(input())
P = list(input())
for i in range(len(T)):
try:
if P[0] == T[i]:
for j in range(len(P)):
if P[j] == T[i + j]:
pass
else: break
else: print(i)
except:pass | p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,241 |
s142424370 | p02247 | u546285759 | 1489234088 | Python | Python3 | py | Accepted | 20 | 7444 | 176 | T = input()
P = input()
tmp2 = []
for i in range(len(T)):
tmp = T[i:].find(P)
if tmp != -1:
tmp2.append(len(T[:i])+tmp)
for s in sorted(set(tmp2)):
print(s) | p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,242 |
s631398340 | p02247 | u724963150 | 1496468245 | Python | Python3 | py | Accepted | 20 | 7408 | 98 | t=input()
p=input()
l_t=len(t)
l_p=len(p)
for i in range(l_t-l_p+1):
if t[i:i+l_p]==p:print(i) | p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,243 |
s440235898 | p02247 | u603049633 | 1496647249 | Python | Python3 | py | Accepted | 30 | 7472 | 93 | t=input()
p=input()
lt=len(t)
lp=len(p)
for i in range(lt-lp+1):
if t[i:i+lp]==p:print(i) | p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,244 |
s808381963 | p02247 | u116766943 | 1500309559 | Python | Python3 | py | Accepted | 30 | 8432 | 749 | from pprint import pprint
__BASE = 1000000007
__MOD = (2**64)
__INV = 13499267949257065399
def main():
s,t = input(),input()
x = len(t)
mp = {}
hashv = 0
for i in range(len(s)):
if i - x >= 0:
hashv = hashv - ord(s[i-x]) * ( __BASE ** (x-1) )
hashv *= __BA... | p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,245 |
s266575498 | p02247 | u539803218 | 1502033033 | Python | Python3 | py | Accepted | 30 | 7532 | 109 | s,p = input(),input()
a = len(p)
c = []
c=[i for i in range(0,len(s)) if s[i:i+a]==p]
for e in c:
print(e) | p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,246 |
s782586030 | p02247 | u539803218 | 1502033387 | Python | Python3 | py | Accepted | 30 | 7528 | 75 | s,p=input(),input()
[print(i) for i in range(0,len(s)) if s[i:i+len(p)]==p] | p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,247 |
s722003280 | p02247 | u539803218 | 1502033447 | Python | Python3 | py | Accepted | 30 | 7524 | 73 | s,p=input(),input()
[print(i) for i in range(len(s)) if s[i:i+len(p)]==p] | p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,248 |
s930866265 | p02247 | u539803218 | 1502033680 | Python | Python3 | py | Accepted | 20 | 7528 | 73 | s,p=input(),input();[print(i) for i in range(len(s)) if s[i:i+len(p)]==p] | p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,249 |
s583017229 | p02247 | u539803218 | 1502035012 | Python | Python3 | py | Accepted | 20 | 7524 | 71 | s,p=input(),input();[print(i)for i in range(len(s))if s[i:i+len(p)]==p] | p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,250 |
s941267911 | p02247 | u614197626 | 1503046078 | Python | Python3 | py | Accepted | 30 | 7476 | 225 | T = input()
P = input()
idx = 0
ans = 1000
while (ans != -1):
ans = T.find(P, idx)
if (ans == -1):
break
else:
print(ans)
if (ans==0):
idx+=1
else:
idx=ans+1 | p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,251 |
s672219549 | p02247 | u614197626 | 1503046099 | Python | Python3 | py | Accepted | 20 | 7428 | 206 | T = input()
P = input()
idx = 0
while (1):
ans = T.find(P, idx)
if (ans == -1):
break
else:
print(ans)
if (ans==0):
idx+=1
else:
idx=ans+1 | p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,252 |
s801844913 | p02247 | u957021183 | 1504244835 | Python | Python3 | py | Accepted | 30 | 7456 | 326 | # Aizu Problem ALDS_1_14_A: Naive Search
#
import sys, math, os
# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
sys.stdin = open("sample-input.txt", "rt")
string = input().strip()
pattern = input().strip()
pos = string.find(pattern)
while pos >= 0:
print(pos)
pos = string.find(pattern, po... | p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,253 |
s334848865 | p02247 | u260980560 | 1508001876 | Python | Python3 | py | Accepted | 40 | 7516 | 135 | T = input()
P = input()
idx = 0
while 1:
idx = T.find(P, idx)
if idx+1:
print(idx)
else:
break
idx += 1 | p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,254 |
s597373715 | p02247 | u798803522 | 1511074932 | Python | Python3 | py | Accepted | 20 | 7516 | 259 | target = input().strip()
se = input().strip()
answer = []
for i in range(len(target) - len(se) + 1):
for inner in range(len(se)):
if target[i + inner] != se[inner]:
break
else:
answer.append(i)
for a in answer:
print(a) | p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,255 |
s552377519 | p02247 | u024715419 | 1513076339 | Python | Python3 | py | Accepted | 30 | 5568 | 107 | t = input()
p = input()
for i in range(len(t) - len(p) + 1):
if t[i:i + len(p)] == p:
print(i) | p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,256 |
s594880678 | p02247 | u426534722 | 1520087509 | Python | Python3 | py | Accepted | 20 | 5576 | 173 | def MAIN():
T = input()
P = input()
t = -1
for _ in range(1000):
t = T.find(P, t + 1)
if t == -1:
break
print(t)
MAIN()
| p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,257 |
s051166853 | p02247 | u150984829 | 1524899500 | Python | Python3 | py | Accepted | 20 | 5576 | 82 | T,P=input(),input()
n=len(P)
for i in range(len(T)-n+1):
if T[i:i+n]==P:print(i)
| p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,258 |
s632084506 | p02247 | u150984829 | 1524899664 | Python | Python3 | py | Accepted | 20 | 5576 | 78 | T,P=input(),input()
n=len(P)
for i in range(len(T)):
if T[i:i+n]==P:print(i)
| p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,259 |
s592979205 | p02247 | u150984829 | 1524899703 | Python | Python3 | py | Accepted | 20 | 5576 | 76 | T,P=input(),input()
n=len(P)
for i in range(len(T)):T[i:i+n]!=P or print(i)
| p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,260 |
s110227907 | p02247 | u150984829 | 1524899756 | Python | Python3 | py | Accepted | 20 | 5568 | 72 | T,P=input(),input()
for i in range(len(T)):T[i:i+len(P)]!=P or print(i)
| p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,261 |
s751273436 | p02247 | u150984829 | 1524899797 | Python | Python3 | py | Accepted | 20 | 5564 | 71 | T,P=input(),input()
for i in range(len(T)):P!=T[i:i+len(P)]or print(i)
| p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,262 |
s244815339 | p02247 | u150984829 | 1524899930 | Python | Python3 | py | Accepted | 20 | 5572 | 75 | T,P=input(),input()
for i in range(len(T)):T[i:].startswith(P)and print(i)
| p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,263 |
s516125124 | p02247 | u126478680 | 1526043353 | Python | Python3 | py | Accepted | 20 | 5572 | 103 |
T = input()
P = input()
for i in range(len(T)-len(P)+1):
if T[i:i+len(P)] == P:
print(i)
| p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,264 |
s438511062 | p02247 | u138546245 | 1527032197 | Python | Python3 | py | Accepted | 20 | 5576 | 387 | def search(s1, s2):
len1 = len(s1)
len2 = len(s2)
for i in range(len1):
if i + len2 > len1:
break
for j in range(len2):
if s1[i+j] != s2[j]:
break
else:
yield i
def run():
s1 = input()
s2 = input()
for idx in search(s... | p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,265 |
s328498441 | p02247 | u925445050 | 1597762560 | Python | Python3 | py | Accepted | 20 | 5568 | 99 | A=input()
B=input()
a=len(A)
b=len(B)
for i in range(a-b+1):
if B==A[i:i+b]:
print(i)
| p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,266 |
s052474752 | p02247 | u627612495 | 1597761112 | Python | Python3 | py | Accepted | 20 | 5564 | 93 | T = input()
P = input()
for i in range(len(T)):
if T[i:].startswith(P):
print(i)
| p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,267 |
s566891356 | p02247 | u326077502 | 1597760711 | Python | Python3 | py | Accepted | 30 | 5572 | 109 | a = input()
b = input()
for i in range(len(a)-len(b)+1):
x = a[i:i+len(b)]
if x==b:
print(i)
| p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,268 |
s952063394 | p02247 | u293306835 | 1597759825 | Python | Python3 | py | Accepted | 20 | 5564 | 114 | T=input()
P=input()
for i in range(len(T)):
if T[i:i+len(P)]==P:
print(i)
else:
continue
| p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,269 |
s262270208 | p02247 | u365131854 | 1597758075 | Python | Python3 | py | Accepted | 20 | 5576 | 97 | t,p=input(),input()
len_p=len(p)
for i in range(len(t)-len_p+1):
if t[i:i+len_p]==p:
print(i)
| p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,270 |
s010539331 | p02247 | u782152619 | 1597751941 | Python | Python3 | py | Accepted | 20 | 5560 | 93 | T = input()
P = input()
for j in range(len(T)):
if T[j:].startswith(P):
print(j)
| p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,271 |
s047280226 | p02247 | u427834127 | 1597737083 | Python | Python3 | py | Accepted | 20 | 5564 | 78 | T=input()
P=input()
for i in range(len(T)):
P!=T[i:i+len(P)] or print(i)
| p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,272 |
s798736218 | p02247 | u118506623 | 1597736193 | Python | Python3 | py | Accepted | 20 | 5572 | 93 | T = input()
P = input()
for i in range(len(T)):
if P == T[i:i+len(P)]:
print(i)
| p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,273 |
s194178531 | p02247 | u476754031 | 1597730529 | Python | Python3 | py | Accepted | 20 | 5568 | 116 | T = input()
P = input()
t = len(T)
p = len(P)
for i in range(t - p + 1):
if T[i : i + p] == P:
print(i)
| p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,274 |
s988367190 | p02247 | u799076010 | 1597687006 | Python | Python3 | py | Accepted | 20 | 5564 | 105 | T=input()
P=input()
b=0
while True:
a=T.find(P,b)
if a==-1:
break
print(a)
b=a+1
| p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,275 |
s015340638 | p02247 | u762022668 | 1597671774 | Python | Python3 | py | Accepted | 20 | 5568 | 93 | T=input()
P=input()
for i in range(len(T)-len(P)+1):
if P==T[i:i+len(P)]:
print(i)
| p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,276 |
s134752850 | p02247 | u981910313 | 1597655471 | Python | Python3 | py | Accepted | 20 | 5572 | 93 | T=input()
P=input()
a=len(P)
for i in range(len(T)):
if(T[i:i+a] == P):
print(i)
| p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,277 |
s281153084 | p02247 | u799016206 | 1597609540 | Python | Python3 | py | Accepted | 20 | 5572 | 102 | t=input()
p=input()
for i in range(len(t)-len(p)+1):
if t[i:i+len(p)] == p:
print(i)
| p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,278 |
s129942282 | p02247 | u829520323 | 1597594309 | Python | Python3 | py | Accepted | 20 | 5572 | 296 | a = list(input())
b = list(input())
for j in range(len(a)+1-len(b)) :
Same = True
ans = j
i = 0
while i < len(b) :
if b[i] == a[j] :
i += 1
j += 1
else :
Same = False
break
if Same == True :
print(ans)
| p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,279 |
s980784310 | p02247 | u322947441 | 1597583474 | Python | Python3 | py | Accepted | 50 | 5568 | 269 | T = input();
P = input();
t = list(T);
p = list(P);
k = 0;
if(P in T):
for j in range(0,len(t)-len(p)+1):
k = 0;
for i in range(0,len(p)):
if t[j+i] == p[i]:
k += 1;
if k == len(p):
print(j);
| p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,280 |
s674643509 | p02247 | u593595530 | 1597576610 | Python | Python3 | py | Accepted | 20 | 5568 | 108 | T = input()
P = input()
for i in range(len(T) - len(P) + 1):
if P == T[i : i + len(P)]:
print(i)
| p02247 |
<H1>Naive String Search</H1>
<p>
Find places where a string <var>P</var> is found within a text <var>T</var>.
Print all indices of <var>T</var> where <var>P</var> found. The indices of <var>T</var> start with 0.
</p>
<H2>Input</H2>
<p>
In the first line, a text <var>T</var> is given. In the second line, a ... | aabaaa
aa
| 0
3
4
| 30,281 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.