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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s504807450 | p02242 | u079141094 | 1468371189 | Python | Python3 | py | Accepted | 20 | 7972 | 806 | # Graph II - Single Source Shortest Path I
def dijkstra(length, adj_m):
INFTY = float('inf')
d = [INFTY for _ in range(length)]
d[0] = 0
Q = [i for i in range(length)]
while Q:
idx = INFTY
minv = INFTY
for q in Q:
if d[q] < minv:
idx, minv = q, d[q... | p02242 |
<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>Single Source Shortest Path... | 5
0 3 2 3 3 1 1 2
1 2 0 2 3 4
2 3 0 3 3 1 4 1
3 4 2 1 0 1 1 4 4 3
4 2 2 1 3 3
| 0 0
1 2
2 2
3 1
4 3
| 30,082 |
s941380078 | p02244 | u578148790 | 1534773015 | Python | Python3 | py | Accepted | 30 | 5612 | 1,338 | N = 8
FREE = 1
NOT_FREE = -1
def initialize():
row = [FREE] * N
col = [FREE] * N
dpos = [FREE] * (2 * N - 1)
dneg = [FREE] * (2 * N - 1)
return row, col, dpos, dneg
def printBoard(x, row):
for i in range(N):
for j in range(N):
if x[i][j]:
if row[i] != j:
... | 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,083 |
s407045718 | p02244 | u279605379 | 1534899973 | Python | Python3 | py | Accepted | 20 | 5616 | 1,135 | def check(a):
flag = True
for i in C:
if (i[0] == a[0]) or (i[1] == a[1]) or (abs(i[0]-a[0]) == abs(i[1]-a[1])):
flag = False
return flag
def recq(r):
if r == 8:
pass
elif DPr[r] == 1:
recq(r+1)
else:
for c in range(8):
if DPc[c]:
... | 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,084 |
s551789718 | p02244 | u726330006 | 1540483668 | Python | Python3 | py | Accepted | 30 | 5640 | 2,538 |
class Chess_board:
def __init__(self):
self.board=[[0]*8 for i in range(8)]
self.queen_array=[]
self.queen_row=[]
def copy_board(chess_board):
new_board=Chess_board()
new_board.board=[chess_board.board[i][:] for i in range(8)]
new_board.queen_array=chess_board.queen_array[:]
... | 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,085 |
s295783488 | p02244 | u799595944 | 1556332882 | Python | Python3 | py | Accepted | 40 | 6348 | 1,240 | import copy
n = int(input())
dotsa = []
for _ in range(n):
y,x = map(int,input().split(" "))
dotsa.append([y,x])
pattern = []
pattern.append(dotsa)
for y in range(8):
nextpattern = []
#print("#######")
#print(pattern)
for pat in pattern:
#print(";;;;;;;;;;;;;;;;;;;;;")
#prin... | 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,086 |
s424072448 | p02244 | u567380442 | 1422493448 | Python | Python3 | py | Accepted | 40 | 6760 | 891 | import sys, itertools
f = sys.stdin
n = int(f.readline())
q = []
rest_r = set(range(8))
rest_c = [i for i in range(8)]
for _ in range(n):
r, c = map(int, f.readline().split())
q.append([r, c, r + c, r - c])
rest_r.remove(r)
rest_c.remove(c)
def check(q, rc):
for qi in q:
if qi[2] =... | 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,087 |
s887580330 | p02244 | u669284080 | 1454075395 | Python | Python3 | py | Accepted | 60 | 7844 | 1,213 | #!/usr/bin/python3
import itertools
def print_boad(boad):
b = [['.' for i in range(8)] for j in range(8)]
for q in boad:
b[q[0]][q[1]] = 'Q'
for i in range(8):
print(''.join(b[i]))
def find_next(base, exist_r, exist_c, exist_lt, exist_rt, invalid):
if len(base) == 8:
print_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,088 |
s911392971 | p02244 | u284474275 | 1454425860 | Python | Python | py | Accepted | 10 | 6492 | 986 | from __future__ import division
import sys
def can_place(pos, idx, col):
for i in range(8):
if pos[i] is not None and pos[i] == col: return False
for i in range(8):
if pos[i] is not None and abs(pos[i] - col) == abs(i - idx): return False
return True
def dfs(pos, depth):
if 8 == depth:... | 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,089 |
s703090161 | p02244 | u284474275 | 1454426722 | Python | Python | py | Accepted | 10 | 6496 | 901 | from __future__ import division
import sys
def can_place(pos, idx, col):
for i in range(8):
if pos[i] is not None and pos[i] == col: return False
for i in range(8):
if pos[i] is not None and abs(pos[i] - col) == abs(i - idx): return False
return True
def dfs(pos, depth):
if 8 == depth:... | 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,090 |
s886241774 | p02244 | u408260374 | 1456534781 | Python | Python3 | py | Accepted | 40 | 7760 | 732 | from itertools import permutations
def check(queen):
for r1, c1 in queen:
if not all((r1 == r2 and c1 == c2) or (r1 != r2 and c1 != c2 and 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))
... | 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,091 |
s636986628 | p02244 | u408260374 | 1456535095 | Python | Python3 | py | Accepted | 70 | 7760 | 694 | from itertools import permutations
def check(queen):
for r1, c1 in queen:
if any((r1 != r2 or c1 != c2) and (r1 == r2 or c1 == c2 or r1 + c1 == r2 + c2 or r1 - c1 == r2 - c2) for r2, c2 in queen):
return False
return True
N = int(input())
queen, row, col = [], list(range(8)), list(range(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,092 |
s789912262 | p02244 | u408260374 | 1456535306 | Python | Python3 | py | Accepted | 70 | 7760 | 655 | from itertools import permutations
def check(queen):
for r1, c1 in queen:
if any((r1 != r2 or c1 != c2) and (r1 == r2 or c1 == c2 or r1 + c1 == r2 + c2 or r1 - c1 == r2 - c2) for r2, c2 in queen):
return False
return True
N = int(input())
Q, row, col = [], list(range(8)), list(range(8))
for ... | 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,093 |
s287725312 | p02244 | u408260374 | 1456535627 | Python | Python | py | Accepted | 30 | 6556 | 580 | import itertools
def check(q):
for r1, c1 in q:
if any((r1 != r2 or c1 != c2) and (r1 == r2 or c1 == c2 or r1 + c1 == r2 + c2 or r1 - c1 == r2 - c2) for r2, c2 in q): return 0
return 1
N = input()
Q, row, col = [], range(8), range(8)
for _ in range(N):
r, c = map(int, raw_input().split())
Q.appe... | 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,094 |
s911080872 | p02244 | u408260374 | 1456535969 | Python | Python | py | Accepted | 40 | 6552 | 526 | import itertools
N, Q, row, col = input(), [], range(8), range(8)
for _ in range(N):
r, c = map(int, raw_input().split())
Q.append((r, c))
row.remove(r)
col.remove(c)
for l in itertools.permutations(col):
queen = Q + list(zip(row, l))
if not any(any((r1 != r2 or c1 != c2) and (r1 == r2 or c1 == ... | 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,095 |
s291404544 | p02244 | u408260374 | 1456536056 | Python | Python | py | Accepted | 30 | 6540 | 521 | import itertools
N, Q, row, col = input(), [], range(8), range(8)
for _ in range(N):
r, c = map(int, raw_input().split())
Q.append((r, c))
row.remove(r)
col.remove(c)
for l in itertools.permutations(col):
queen = Q + list(zip(row, l))
if not any((r1 != r2 or c1 != c2) and (r1 == r2 or c1 == c2 o... | 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,096 |
s653443887 | p02244 | u408260374 | 1456567214 | Python | Python3 | py | Accepted | 30 | 7816 | 706 | 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 = []
for _ in range(... | 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,097 |
s032341122 | p02244 | u408260374 | 1456567290 | Python | Python | py | Accepted | 30 | 6564 | 497 | import itertools
N, Q, row, col = input(), [], range(8), range(8)
for _ in range(N):
r, c = map(int, raw_input().split())
Q.append((r, c))
row.remove(r)
col.remove(c)
for l in itertools.permutations(col):
queen = Q + list(zip(row, l))
if not any((r1 != r2 or c1 != c2) and (r1 + c1 == r2 + c2 or ... | 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,098 |
s860057962 | p02244 | u731710433 | 1457508335 | Python | Python3 | py | Accepted | 50 | 7792 | 851 | def try_set(v):
def print_board():
for (r, c) in preset:
if queen_pos[r] != c:
return
for pos in queen_pos:
for c in range(8):
print('Q' if c == pos else '.', end='')
print()
for h in range(8):
if all((horizontal[h], di... | 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,099 |
s453350715 | p02244 | u022407960 | 1481123513 | Python | Python3 | py | Accepted | 40 | 7812 | 1,559 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
input:
2
2 2
5 3
output:
......Q.
Q.......
..Q.....
.......Q
.....Q..
...Q....
.Q......
....Q...
"""
import sys
N = 8
FREE, NOT_FREE = -1, 1
def generate_board(_q_list):
for queen in _q_list:
x, y = map(int, queen)
init_q_check[x][y] = True
... | 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,100 |
s586271072 | p02244 | u022407960 | 1481125124 | Python | Python3 | py | Accepted | 40 | 7816 | 1,446 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
input:
2
2 2
5 3
output:
......Q.
Q.......
..Q.....
.......Q
.....Q..
...Q....
.Q......
....Q...
"""
import sys
N = 8
FREE, NOT_FREE = -1, 1
def generate_board(_q_list):
for queen in _q_list:
x, y = map(int, queen)
init_q_check[x][y] = True
... | 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,101 |
s646352745 | p02244 | u603049633 | 1496626625 | Python | Python3 | py | Accepted | 30 | 7792 | 654 | from itertools import permutations as per
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
k = int(input())
R, C = [i for i in range(8)],[i for i in range(8)]
q = []
for _... | 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,102 |
s522201053 | p02244 | u426534722 | 1500218538 | Python | Python3 | py | Accepted | 40 | 7796 | 953 | from sys import stdin
N = 8
FREE = -1
NOT_FREE = 1
row = [FREE] * N
col = [FREE] * N
dpos = [FREE] * (2 * N - 1)
dneg = [FREE] * (2 * N - 1)
X = [[False] * N for _ in range(N)]
n = int(stdin.readline())
for _ in range(0, n):
r, c = map(int, stdin.readline().split())
X[r][c] = True
def printBoard():
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,103 |
s544879370 | p02244 | u426534722 | 1500219302 | Python | Python3 | py | Accepted | 50 | 7796 | 922 | from sys import stdin
N = 8
FREE = -1
NOT_FREE = 1
row = [FREE] * N
col = [FREE] * N
dpos = [FREE] * (2 * N - 1)
dneg = [FREE] * (2 * N - 1)
X = [[False] * N for _ in range(N)]
n = int(stdin.readline())
for _ in range(0, n):
r, c = map(int, stdin.readline().split())
X[r][c] = True
def printBoard():
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,104 |
s549563220 | p02244 | u426534722 | 1500220457 | Python | Python3 | py | Accepted | 40 | 7796 | 909 | from sys import stdin
N = 8
FREE = -1
NOT_FREE = 1
row = [FREE] * N
col = [FREE] * N
dpos = [FREE] * (2 * N - 1)
dneg = [FREE] * (2 * N - 1)
X = [[False] * N for _ in range(N)]
n = int(stdin.readline())
for _ in range(0, n):
r, c = map(int, stdin.readline().split())
X[r][c] = True
def printBoard():
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,105 |
s306395293 | p02244 | u426534722 | 1500222177 | Python | Python3 | py | Accepted | 30 | 7784 | 649 | from sys import stdin
from itertools import permutations as per
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
k = int(stdin.readline())
R, C = [[i for i in range(8)] for ... | 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,106 |
s626552226 | p02244 | u426534722 | 1500222671 | Python | Python3 | py | Accepted | 30 | 7784 | 634 | from sys import stdin
from itertools import permutations as per
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
k = int(stdin.readline())
R, C = [[i for i in range(8)] for ... | 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,107 |
s440483925 | p02244 | u533883485 | 1502107197 | Python | Python3 | py | Accepted | 30 | 7912 | 3,031 | # coding=utf-8
class Tree():
def __init__(self, init_field):
self.root = init_field
def search(self, field_id, field):
global final_queen_pos
#print("field_id:", field_id)
#field.print_field()
q_r = rest_row[field_id - n]
if final_queen_pos:
return N... | 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,108 |
s986572563 | p02244 | u533883485 | 1502107213 | Python | Python3 | py | Accepted | 30 | 7904 | 3,031 | # coding=utf-8
class Tree():
def __init__(self, init_field):
self.root = init_field
def search(self, field_id, field):
global final_queen_pos
#print("field_id:", field_id)
#field.print_field()
q_r = rest_row[field_id - n]
if final_queen_pos:
return N... | 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,109 |
s880499684 | p02244 | u491916705 | 1503134561 | Python | Python | py | Accepted | 10 | 6492 | 1,000 | n = int(raw_input())
N = 8
data = [['.' for i in range(N)] for j in range(N)]
row = [0 for i in range(N)]
col = [0 for i in range(N)]
dpos = [0 for i in range(2*N-1)]
dneg = [0 for i in range(2*N-1)]
for i in range(n):
tmp = map(int, raw_input().split())
data[tmp[0]][tmp[1]] = 'Q'
row[tmp[0]] = 1; col[tmp[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,110 |
s941843568 | p02244 | u072053884 | 1506932622 | Python | Python3 | py | Accepted | 30 | 7872 | 1,075 | row = [True] * 8
col = [True] * 8
dpos = [True] * 15
dneg = [True] * 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] = "INIT"
col[c] = "INIT"
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,111 |
s187982552 | p02244 | u798803522 | 1510238959 | Python | Python3 | py | Accepted | 100 | 7912 | 1,373 | def place(board, x, y, num, answer):
width = len(board[0])
r_dx = (x + 1) % width
r_dy = (y + 1) % width
for i in range(width - 1):
board[y][(x + i + 1) % width] += num
board[(y + i + 1) % width][x] += num
div = [1,1,-1,-1]
for i in range(4):
x_i = div[(0 + i) % 4]
... | 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,112 |
s039496781 | p02244 | u248416507 | 1510988744 | Python | Python | py | Accepted | 10 | 6492 | 1,412 | import sys
def print_board(board):
for y in xrange(8):
for x in xrange(8):
if x == board[y]:
sys.stdout.write("Q")
else:
sys.stdout.write(".")
print ""
# y = x - col + row
# y = - x + col + row
def check_threat(board, col, row):
for 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,113 |
s053252413 | p02244 | u262566745 | 1511154895 | Python | Python3 | py | Accepted | 60 | 7844 | 965 | n = int(input())
nt = []
board = [["." for _ in range(8)] for _ in range(8)]
for i in range(n):
y, x = map(int, input().split())
board[y][x] = "Q"
nt.append(y)
def output():
for row in board:
print("".join(row), sep=None)
def check(x, y):
for i in range(8):
for j in range(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,114 |
s314200262 | p02244 | u024715419 | 1512113352 | Python | Python3 | py | Accepted | 70 | 5612 | 1,295 | def changeBoard(board, i, j, d):
n = 8
for k in range(n):
board[i][k] += d
board[k][j] += d
if i > j:
for k in range(n - i + j):
board[k + i - j][k] += d
else:
for k in range(n - j + i):
board[k][k + j - i] += d
if i + j < n:
for k in 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,115 |
s239079107 | p02244 | u236679854 | 1521396153 | Python | Python3 | py | Accepted | 20 | 5612 | 1,193 | N = 8
board = [['.'] * N for i in range(N)]
k = int(input())
for i in range(k):
pos = list(map(int, input().split()))
board[pos[0]][pos[1]] = 'Q'
def is_safe(board, row, col):
for i in range(N):
if board[row][i] == 'Q':
return False
for i, j in zip(range(row, -1, -1), range(col, -... | 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,116 |
s613534146 | p02244 | u662418022 | 1523449808 | Python | Python3 | py | Accepted | 20 | 5624 | 1,060 | # -*- coding: utf-8 -*-
if __name__ == '__main__':
N = 8
FREE = -1
NOT_FREE = 1
row = [FREE] * N
col = [FREE] * N
dpos = [FREE] * (2 * N - 1)
dneg = [FREE] * (2 * N - 1)
X = [["." for _ in range(N)] for _ in range(N)]
k = int(input())
for _ in range(k):
i, j = 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,117 |
s810008311 | p02244 | u466299927 | 1523963073 | Python | Python3 | py | Accepted | 20 | 5636 | 2,459 | # -*- coding: utf-8 -*-
import sys
BOARD_SIZE_W = 8
BOARD_SIZE_H = 8
def set_queen(board, queen_point):
"""
クイーンを指定座標に配置した後、残りの配置可能な位置の配列を返す
"""
return filter(create_queen_filter(queen_point), board)
def create_queen_filter(queen_point):
"""
指定位置にクイーンを配置したことにより、対象座標へ配置不可能にならないかを確認する関数を返す
... | 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,118 |
s432673062 | p02244 | u167493070 | 1525687642 | Python | Python3 | py | Accepted | 30 | 5624 | 1,412 | import sys;
def putQueen(i, row, col, dpos, dneq):
global finding
if(finding == 0):
return
if(i == 8):
finding = 0
printBoard(row[0:])
return
for j in range(8):
if i in myset:
putQueen(i+1,row[0:], col[0:], dpos[0:], dneq[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,119 |
s756611928 | p02244 | u825008385 | 1525759254 | Python | Python3 | py | Accepted | 20 | 5616 | 1,340 | # 8 Queens Problem
[N, FREE, NOT_FREE] = [8, -1, 1]
initial_Q = [FREE for i in range(N)]
row = [FREE for i in range(N)]
col = [FREE for i in range(N)]
dneg = [FREE for i in range(N*2 - 1)]
dpos = [FREE for i in range(N*2 - 1)]
k = int(input())
for i in range(k):
[r, c] = list(map(int, input().split()))
initial... | 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,120 |
s757968027 | p02244 | u960937651 | 1525767137 | Python | Python3 | py | Accepted | 30 | 5620 | 1,050 | N_ = 8
FREE_ = -1
NOTFREE_ = 1
row = [FREE_ for i in range(N_)]
col = [FREE_ for i in range(N_)]
dpos = [FREE_ for i in range(2*N_-1)]
dneg = [FREE_ for i in range(2*N_-1)]
X = [[False for i in range(N_)] for j in range(N_)]
def output():
for i in range(N_):
for j in range(N_):
if X[i][j]:
... | 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,121 |
s656582207 | p02244 | u265136581 | 1526029680 | Python | Python3 | py | Accepted | 20 | 5616 | 919 |
N = 8 # クイーンの数
n = int(input())
raw = [-1 for i in range(N)]
col = [0 for i in range(N)] # FREE: 0, NOT_FREE: 1
dpos = [0 for i in range(2*N-1)] # FREE: 0, NOT_FREE: 1
dneg = [0 for i in range(2*N-1)] # FREE: 0, NOT_FREE: 1
def put_queen(i):
if i == N:
return True
elif raw[i] != -1:
if put_queen(i+1):
retu... | 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,122 |
s502956396 | p02244 | u408284582 | 1526059398 | Python | Python3 | py | Accepted | 20 | 5612 | 1,039 | N = 8
def putQueen(i):
if i == N:
printBoard()
return
if i in default:
putQueen(i+1)
else:
for j in range(N):
if col [j] or \
dpos[i+j] or \
dneg[i-j+N-1]:
continue
tmp = row[i]
row[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,123 |
s558393458 | p02244 | u126478680 | 1526228055 | Python | Python3 | py | Accepted | 30 | 6348 | 1,481 | from enum import Enum, auto
class Square(Enum):
FREE = auto()
NOT_FREE = auto()
row = [Square.FREE for i in range(8)]
col = [Square.FREE for i in range(8)]
dpos = [Square.FREE for i in range(2*8-1)]
dneg = [Square.FREE for i in range(2*8-1)]
board = [[False for j in range(8)] for i in range(8)]
def set_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,124 |
s914103722 | p02244 | u893844544 | 1526277046 | Python | Python3 | py | Accepted | 20 | 5616 | 816 | FREE = -1
NOT_FREE = 1
N = 8
B = [["."] * N for _ in range(N)]
row = [FREE] * N
col = [FREE] * N
dpos = [FREE] * (2 * N - 1)
dneg = [FREE] * (2 * N - 1)
def update(r, c, FREE_OR_NOT):
B[r][c] = "." if FREE_OR_NOT == FREE else "Q"
row[r] = col[c] = dpos[r + c] = dneg[r - c + N - 1] = FREE_OR_NOT
def draw():
... | 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,125 |
s946724275 | p02244 | u011621222 | 1526536992 | Python | Python3 | py | Accepted | 30 | 5616 | 1,287 | def queenprint() :
global x
global col
global row
global k
global maxx
for i in range(maxx):
for j in range(maxx):
if x[i][j] and row[i] != j:
return
for i in range(maxx):
for j in range(maxx):
if row[i]==j:
... | 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,126 |
s624651128 | p02244 | u138546245 | 1526779817 | Python | Python3 | py | Accepted | 60 | 6352 | 2,181 | from copy import deepcopy
class EightQueen:
NQUEENS = 8
SIZE = 8
class Board:
def __init__(self, size):
self.queens = []
self.size = size
def place(self, i, j):
self.queens.append((i, j))
def count(self):
return len(self.queens)
... | 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,127 |
s233567598 | p02244 | u318430977 | 1530288539 | Python | Python3 | py | Accepted | 30 | 5664 | 896 | from itertools import permutations
def check(queen):
for r1, c1 in queen:
for r2, c2 in queen:
if r1 == r2 and c1 == c2:
break
if r1 == r2:
return False
if c1 == c2:
return False
if r1 + c1 == r2 + c2:
... | 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,128 |
s810673223 | p02244 | u519227872 | 1530632300 | Python | Python3 | py | Accepted | 20 | 5620 | 656 | 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 solve(i):
while i < 8 and not row[i]:i += 1
if 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,129 |
s379059104 | p02244 | u733357255 | 1597872637 | Python | Python3 | py | Accepted | 50 | 6064 | 1,280 |
from collections import namedtuple
position = namedtuple("position","row column")
def input_queens():
queens = []
n = int(input())
for _ in range(n):
row,column = [int(x) for x in input().split()]
queens.append(position(row,column))
return queens
def output_board(queens):
for r 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,130 |
s098490172 | p02244 | u684853980 | 1595653308 | Python | Python3 | py | Accepted | 70 | 5668 | 1,068 | from itertools import permutations
n = int(input())
q = [list(map(int, input().split())) for _ in range(n)]
for p in permutations(range(8), 8):
if all(p[i] == j for i, j in q):
m = [["."] * 8 for _ in range(8)]
for i, j in enumerate(p):
m[i][j] = "Q"
b = True
for i, j 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,131 |
s290021128 | p02244 | u752764084 | 1594919703 | Python | Python3 | py | Accepted | 40 | 5656 | 726 | from itertools import permutations
k = int(input())
rc = [list(map(int, input().split())) for i in range(k)]
for x in permutations(range(8)):
flag = False
for i in rc:
if x[i[1]] != i[0]:
flag = True
break
if flag:
continue
# 斜めの処理
for i in range(7):
... | 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,132 |
s990118361 | p02244 | u108855621 | 1594744027 | Python | Python3 | py | Accepted | 100 | 5644 | 1,505 | import sys
from itertools import permutations
def in_board(r, c):
return 0 <= r < 8 and 0 <= c < 8
def reachable_generator(r, c):
# 斜め(左上-右下)
i = 1
while True:
if not in_board(r - i, c - i):
break
yield r - i, c - i
i += 1
i = 1
while True:
if not ... | 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,133 |
s896936562 | p02244 | u849721539 | 1594738420 | Python | Python3 | py | Accepted | 40 | 6472 | 2,149 | N=int(input())
L=[[0 for i in range(8)]for j in range(8)]
Q=[]
for i in range(N):
h,w=map(int,input().split())
Q.append((h,w))
#L[h][w]="Q"
if N==8:
L=[["." for i in range(8)]for j in range(8)]
for q in Q:
#print(q)
L[q[0]][q[1]]="Q"
for h in range(8):
print("".join(L[h... | 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,134 |
s547876070 | p02244 | u450519077 | 1594452948 | Python | Python3 | py | Accepted | 30 | 5668 | 773 | 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)) #まだ置ける
qu... | 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,135 |
s102864842 | p02244 | u802474686 | 1594211747 | Python | Python3 | py | Accepted | 30 | 5656 | 714 | from itertools import permutations
n=int(input())
lst_ini=[list(map(int,input().split())) for _ in range(n)]
row=list(range(8))
col=list(range(8))
for x in lst_ini:
row.remove(x[0])
col.remove(x[1])
for x in permutations(col):
work=lst_ini[:]
for i in range(8-n):
work.append([row[i],x[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,136 |
s692479983 | p02244 | u357050809 | 1593764221 | Python | Python3 | py | Accepted | 40 | 6568 | 1,484 | import pprint
inp = int(input())
N = 8
board = [ [0]*8 for _ in range(8) ]
defined = []
dic = {}
for _ in range(inp):
x,y = map(int,input().split())
board[x][y] = 1
defined.append(x)
dic[x] = y
def check(board, row, col):
for i in range(8):
if i==col: continue
if board[row][i] == 1:
return Fal... | 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,137 |
s614360802 | p02244 | u917514663 | 1593006052 | Python | Python3 | py | Accepted | 60 | 10552 | 701 | from itertools import permutations
n=int(input())
q=[list(map(int,input().split())) for _ in range(n)]
l=list(range(8))
Q=list(permutations(l,8))
def OK(s):
a=list(s)
b=list(s)
for i in range(len(s)):
a[i]-=i
b[i]+=i
for i,j in enumerate(a[:-1]):
if j in a[i+1:]:
retu... | 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,138 |
s956091110 | p02244 | u180322859 | 1592504004 | Python | Python3 | py | Accepted | 70 | 5652 | 965 | from itertools import permutations
n = int(input())
li = [list(map(int,input().split())) for _ in range(n)]
chess = [["." for i in range(8)]for j in range(8)]
for i in range(8):
chess[i][i] = "Q"
point = 0
# 行のchessの並べ方を探索
for patern in permutations(chess):
for y,x in li:
if patern[y][x] != "Q":
... | 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,139 |
s275785242 | p02244 | u040807768 | 1592400548 | Python | Python3 | py | Accepted | 60 | 10544 | 664 | import itertools
K = int(input())
RC = [list(map(int,input().split())) for _ in range(K)]
P = list(itertools.permutations([0,1,2,3,4,5,6,7]))
PP = []
for p in P:
for rc in RC:
if p[rc[0]] != rc[1]:
break
else:
PP.append(p)
for pp in PP:
for i in range(8):
for j in range(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,140 |
s053288707 | p02244 | u057134693 | 1592314568 | Python | Python3 | py | Accepted | 40 | 6320 | 956 | # 17
# ALDS_13_A-8 クイーン問題
import itertools
import copy
k = int(input())
q_l = [[int(x) for x in input().split()] for y in range(k)]
x_l = list(range(8))
y_l = list(range(8))
plus_l = []
minus_l = []
for i in range(k):
x_l.remove(q_l[i][1])
y_l.remove(q_l[i][0])
plus_l.append(q_l[i][0] + q_l[i][1])
mi... | 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,141 |
s528170546 | p02244 | u476858890 | 1591450158 | Python | Python3 | py | Accepted | 30 | 5656 | 1,033 | from itertools import permutations
k = int(input())
rc = [list(map(int, input().split())) for _ in range(k)]
field = [["."] * 8 for _ in range(8)]
# 列
column = [i for i in range(8)]
# 行
row = [i for i in range(8)]
for r, perm_column in rc:
column.remove(perm_column)
row.remove(r)
field[r][perm_column] ... | 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,142 |
s072399961 | p02244 | u156732351 | 1591235870 | Python | Python3 | py | Accepted | 50 | 5644 | 701 | import itertools
k = int(input())
coords = [tuple(map(int, input().split())) for _ in range(k)]
for item in itertools.permutations(range(8)):
for x, y in coords:
if item[x] != y:
break
else:
for i, j in enumerate(item):
for k in range(1, 8):
if i+k < 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,143 |
s034609173 | p02244 | u798363880 | 1591202762 | Python | Python3 | py | Accepted | 30 | 5656 | 1,074 | import itertools
queen=[-1]*8
N=int(input())
de=[]
for i in range(N):
x,y =list(map(int,input().split()))
de.append(x)
queen[x]=y
def check(n):#nはクイーンの個数
for y in range(n):
if crshu(queen[y],y):return False
return True
def crshu(x,y):
for y1 in range(y):
x1=queen[y1]
if 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,144 |
s338484244 | p02244 | u512068851 | 1591180280 | Python | Python3 | py | Accepted | 20 | 5660 | 631 | import itertools
k = int(input())
area = [["."]*8 for i in range(8)]
X = set(range(8))
Y = set(range(8))
A = set()
B = set()
for i in range(k):
x, y = map(int, input().split())
area[x][y] = "Q"
X.remove(x)
Y.remove(y)
A.add(x-y)
B.add(x+y)
for v in itertools.permutations(Y):
ok = 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,145 |
s503220371 | p02244 | u430457144 | 1590303035 | Python | Python3 | py | Accepted | 30 | 5652 | 743 | from itertools import permutations
k = int(input())
points = [tuple(map(int, input().split(' '))) for _ in range(k)]
indexes = set(range(8))
xs = indexes - {x for _, x in points}
ys = list(indexes - {y for y, _ in points})
result = None
for x_indexes in permutations(xs):
selected = set(points)
for i, x in en... | 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,146 |
s318898544 | p02244 | u186154476 | 1589896171 | Python | Python3 | py | Accepted | 20 | 5624 | 1,279 | board = [['#']*8 for i in range(8)]
n = int(input())
v1=[0]*8
v2=[0]*8
v3=[0]*16
v4=[0]*16
def dot(y,x):
for j in range(8):
board[y][j]='.'
board[j][x]='.'
for i in range(1,min(x,y)+1):
board[y-i][x-i]='.'
for i in range(1,min(7-x,y)+1):
board[y-i][x+i]='.'
for i in ran... | 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,147 |
s780697229 | p02244 | u893763407 | 1589865501 | Python | Python3 | py | Accepted | 30 | 5668 | 1,267 | 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())
# 0~7のリストを作成する
R = list(range(8))
C = list(range(8))
# R,Cから既にクイーン... | 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,148 |
s827538440 | p02244 | u761821323 | 1589697022 | Python | Python3 | py | Accepted | 70 | 6620 | 1,163 | #from math import gcd
from math import factorial as f
from math import ceil,floor,sqrt
import bisect
import re
import heapq
from copy import deepcopy
import itertools
from itertools import permutations
from sys import exit
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(... | 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,149 |
s515793300 | p02244 | u974760720 | 1589623277 | Python | Python3 | py | Accepted | 20 | 5616 | 663 | def putQueen(i):
while i < 8 and row[i]:i += 1
if i == 8:
for i in range(8):
print(''.join(queen[i]))
for j in range(8):
if col[j] or dpos[i+j] or dneg[i-j+7]: continue
queen[i][j] = 'Q'
row[i] = col[j] = dpos[i+j] = dneg[i-j+7] = 1
putQueen(i+1)
q... | 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,150 |
s874170706 | p02244 | u514736086 | 1589610988 | Python | Python3 | py | Accepted | 30 | 5620 | 1,018 | N = 8
FREE = -1
NOT_FREE = 1
row = [FREE for _ in range(N)]
col = [FREE for _ in range(N)]
dpos = [FREE for _ in range(2*N-1)]
dneg = [FREE for _ in range(2*N-1)]
X = [[False for _ in range(N)] for _ in range(N)]
def printBoard():
i,j = 0, 0
for i in range(N):
for j in range(N):
if X[i][j... | 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,151 |
s211471930 | p02244 | u043253224 | 1589462443 | Python | Python3 | py | Accepted | 30 | 5624 | 2,524 | class eight_Q:
#Free = 'Free', NOT_Free = 'NotFree'
N = 8
def __init__(self):
#self.position = [['Free' for i in range(self.N)] for j in range(self.N)]
self.row = [-1 for _ in range(self.N)]
self.col = ['Free' for _ in range(self.N)]
self.dpos = ['Free' for _ in range(self.N... | 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,152 |
s124889302 | p02244 | u070358620 | 1589396625 | Python | Python3 | py | Accepted | 20 | 5632 | 3,283 | # バックトラック法
class EightQueens:
def __init__(self,p):
self.p = p
# 前提 8*8の盤
self.N = 8
# 下準備
# row[k] : k行目におけるクイーンの列番号
self.row = [None] * 8
# col[n] : n列目上にクイーンがなければFREE,あればNOT_FREE,それが8列分
self.col = ['FREE'] * 8
# 8 * 8 のマスに対角線を引いていくと15本引くことがで... | 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,153 |
s204475987 | p02244 | u217435805 | 1589328217 | Python | Python3 | py | Accepted | 30 | 5624 | 1,498 | import sys
# sys.stdin = open('input.txt')
def print_board(board):
for i in range(n):
for j in range(n):
if board[i][j] and row[i] != j:
return
for i in range(n):
for j in range(n):
if row[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,154 |
s474975132 | p02244 | u855675048 | 1589180917 | Python | Python3 | py | Accepted | 40 | 6352 | 1,824 | N = int(input())
board_size = 8
board = [[ '.' for _ in range(board_size)] for _ in range(board_size)]
def print_board(board):
for bb in board:
line = ""
for b in bb:
line = line + b
print(line)
#print_board(board)
Q_list = list()
for _ in range(N):
Q_list.append(tuple(map(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,155 |
s055792217 | p02244 | u495295476 | 1589167616 | Python | Python3 | py | Accepted | 40 | 5668 | 784 | k = int(input())
q = [list(map(int, input().split())) for _ in range(k)]
import itertools
row = list(range(0,8))
for i in q:
row.remove(i[0])
col = list(range(0,8))
for i in q:
col.remove(i[1])
for i in itertools.permutations(list(range(0,8-k)),8-k):
queens = []
for j in range(k):
queens.appen... | 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,156 |
s895342672 | p02244 | u821731567 | 1588901162 | Python | Python3 | py | Accepted | 90 | 5904 | 3,556 | def main():
import itertools
k = int(input())
cr_lis = []
for _ in range(k):
cr_lis.append(list(map(int, input().split())))
eight_lis = [x for x in range(8)]
per_lis = itertools.permutations(eight_lis)
for test in per_lis:
#print(test)
cnt = 0
tmp = 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,157 |
s468260295 | p02244 | u610816226 | 1588762468 | Python | Python3 | py | Accepted | 40 | 5660 | 882 | k = int(input())
Qs = [tuple(map(int, input().split())) for _ in range(k)]
from itertools import permutations
Lis = [(i, j) for i in range(8) for j in range(8)]
def dfs(idx, lis):
if idx==8:
return lis
Xs = set([x for x, y in lis])
Ys = set([y for x, y in lis])
Dif = set([x-y for x, y in lis])
... | 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,158 |
s497987395 | p02244 | u848622255 | 1588760601 | Python | Python3 | py | Accepted | 30 | 5624 | 4,924 | #N = int(input())
# class Queen():
# def __init__(self, x,y):
# self.x =x
# self.y = y
# self.right = self.x + self.y
# self.left = abs(self.x -self.y)
#
#
#
# queen_row = [False for _ in range(8)]
# queen_col = [False for _ in range(8)]
# ups = [False for _ in range(2 * 8 -1)]
# dow... | 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,159 |
s540571819 | p02244 | u145526353 | 1588669599 | Python | Python3 | py | Accepted | 30 | 5660 | 1,110 | # 8 queens
import itertools
# x座標が全部異なる
# y座標が全部異なる
# 8C2でx座標の差分とy座標の差分が異なる
# 列挙して含まれるものを挙げる
def check(queens):
for r1, c1 in queens:
for r2, c2 in queens:
# 同じ座標の時は気にしない
if r1 == r2 and c1 == c2:
continue
if (r1 == r2) or (c1 == c2):
re... | 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,160 |
s334414992 | p02244 | u772853944 | 1588229818 | Python | Python3 | py | Accepted | 20 | 5624 | 1,456 | # coding: utf-8
import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces
def permutation(ret: list, leftovers: list) -> list:
if len(leftovers) == 0:
yield ret
for left in leftovers:
... | 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,161 |
s434720871 | p02244 | u356546564 | 1588003149 | Python | Python3 | py | Accepted | 30 | 5736 | 890 | from itertools import permutations
k = int(input())
r = [0] * k; c = [0] * k;
for i in range(k):
r[i], c[i] = [int(a) for a in input().split()]
r_avail = list(range(8))
c_avail = list(range(8))
for i in range(k):
r_avail.remove(r[i])
c_avail.remove(c[i])
cperms = list(permutations(c_avail, 8 - k))
for ... | 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,162 |
s137323959 | p02244 | u093588014 | 1587671682 | Python | Python3 | py | Accepted | 90 | 10548 | 771 | from itertools import permutations as per
z=int(input())
chk=[]
for i in range(z):
chk.append([int(i) for i in input().split()])
a=list(range(8))
pera=list(per(a))
k=0
for i in pera:
st1=set() ; st2=set() ; flag=0
for j in range(z):
if i[chk[j][0]]!=chk[j][1]:
flag=1
break
... | 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,163 |
s573816766 | p02244 | u583793648 | 1587582025 | Python | Python3 | py | Accepted | 100 | 10464 | 537 | import itertools
p = list(itertools.permutations(range(8)))
n = int(input())
k = [list(map(int,input().split())) for i in range(n)]
for d in p:
f = True
for r,c in k:
if d[r]!=c:
f = False
if not f:continue
for i in range(8):
for j in range(8):
if i==j:continue
... | 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,164 |
s940073460 | p02244 | u481381669 | 1587103159 | Python | Python3 | py | Accepted | 20 | 5612 | 1,634 | 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,165 |
s148533001 | p02244 | u909811933 | 1586763393 | Python | Python3 | py | Accepted | 80 | 10672 | 1,172 | import itertools
import math
n = int(input())
placed = []
for i in range(n):
a = list(map(int,input().split()))
placed.append(a)
l = list(range(8))
perm = tuple(itertools.permutations(l))
for v in perm:
flag = True
for j in range(len(placed)):
if v[placed[j][0]] != placed[j][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,166 |
s107235023 | p02244 | u159581881 | 1586416759 | Python | Python3 | py | Accepted | 40 | 6356 | 607 | from copy import copy,deepcopy
import itertools
k=int(input())
b=[['.']*8 for i in range(8)]
R=set(range(8))
C=set(range(8))
p=set()
m=set()
for i in range(k):
r,c=map(int,input().split())
b[r][c]='Q'
R.remove(r);C.remove(c)
p.add(r+c)
m.add(r-c)
for x in itertools.permutations(C):
P=p.copy()
... | 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,167 |
s499385624 | p02244 | u013374192 | 1586186628 | Python | Python3 | py | Accepted | 50 | 6900 | 2,046 | import math
import copy
import sys
import fractions
# import numpy as np
# import statistics
import decimal
import heapq
import collections
import itertools
# from operator import mul
# sys.setrecursionlimit(100001)
# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)
# ===FUNCTION===
def getInputIntList(... | 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,168 |
s721005458 | p02244 | u820842907 | 1586067329 | Python | Python3 | py | Accepted | 30 | 5620 | 1,211 | N = 8
flag_row = [False]*N
flag_col = [False]*N
flag_diag_right = [False]*(2*N-1)
flag_diag_left = [False]*(2*N-1)
B = [ [False for n in range(N)] for n in range(N)]
def ShowBoard():
for i in range(N):
for j in range(N):
if B[i][j] :
if flag_row[i] != j:
ret... | 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,169 |
s658737233 | p02244 | u639594975 | 1585985794 | Python | Python3 | py | Accepted | 30 | 5620 | 1,424 | queenExists = [[False] * 8 for _ in range(8)]
n = int(input())
for _ in range(n):
x, y = map(int, input().split())
queenExists[y][x] = True
def dfs(queenExists, c):
if c >= 8:
return True
# check if queen exists in column c
isQueen = False
for r in range(8):
if queenExists[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,170 |
s865632497 | p02244 | u243094114 | 1585920098 | Python | Python3 | py | Accepted | 60 | 5684 | 1,891 | from itertools import permutations
BLANK = 0
Q = 1
WALL = 2
def to_board_pos(x, y):
return x * 10 + y
def place_queen(pos, board):
assert board[pos] != WALL
if board[pos] == Q:
return False, None
board[pos] = Q
directions = [-10, -9, 1, 11, 10, 9, -1, -11]
for d in directions:
... | 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,171 |
s823256348 | p02244 | u942920884 | 1585179517 | Python | Python3 | py | Accepted | 50 | 6332 | 1,379 | import itertools
import copy
def is_safe(qweens):
x = []
y = []
for q in qweens:
x.append(q[0])
y.append(q[1])
if len(set(x)) + len(set(y)) != len(qweens) * 2:
return False
for q1, q2 in itertools.combinations(qweens, 2):
slope = (q1[0] - q2[0]) / (q1[1] - q2[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,172 |
s751591830 | p02244 | u129426023 | 1585034485 | Python | Python3 | py | Accepted | 40 | 5616 | 2,291 | # import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd
def resolve():
N = 8
# すでに配置されたクイーンの効きが及ばない位置であればTrueを返す
def check(row, FR):
# まず横の効きで取られないかチェックする
# すでにクイーンの配置された行だとダメ
if row in FR:
return 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,173 |
s163695159 | p02244 | u486404145 | 1584609663 | Python | Python3 | py | Accepted | 30 | 5668 | 1,479 | # -*- coding: utf-8 -*-
import sys
from itertools import permutations
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()
def main():
mx=[1,1,-1,-1]
my=[1,-1,1,-1]
def check(tmp_board):
for y,x in enumerate(tmp_board):
d=[1,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,174 |
s605013949 | p02244 | u009853378 | 1584171964 | Python | Python3 | py | Accepted | 50 | 5672 | 791 | import itertools
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))
n = ii()
A = [tuple(int(i) for i in input().split()) for _ in range(n)]
ban = [['.'] * 8 for i in range(8)]
# for i in A:
# ban[i[0]][i[1]] = '.'
for i in itertools.permutations(range... | 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,175 |
s562100664 | p02244 | u648981052 | 1584112674 | Python | Python3 | py | Accepted | 90 | 5660 | 637 | import itertools
K = int(input())
Q = [[int(i) for i in input().split()] for _ in range(K)]
li = list(range(8))
P = itertools.permutations(li, 8)
for p in P:
is_ok = True
for row, col in Q:
if(p[row]!=col):
is_ok = False
break
else:
for ind,i in enumerate(p):
... | 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,176 |
s997924325 | p02244 | u853158149 | 1584027102 | Python | Python3 | py | Accepted | 100 | 6080 | 1,373 | #!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdi... | 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,177 |
s803556852 | p02244 | u440554255 | 1584012842 | Python | Python3 | py | Accepted | 100 | 5680 | 1,258 | import itertools
def sumdiag(board, k):
if (k >= 0):
s = 0
for i in range(len(board) - k):
s += board[i][i + k]
return s
else:
k = -k
s = 0
for i in range(len(board) - k):
s += board[i + k][i]
return s
def fliplr(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,178 |
s309110609 | p02244 | u284842807 | 1583463786 | Python | Python3 | py | Accepted | 30 | 5652 | 592 | import itertools
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
k = int(input())
R, C = [[i for i in range(8)] for _ in range(2)]
q = []
for _ in range(k):
r, c = ma... | 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,179 |
s847106300 | p02244 | u910017046 | 1583237840 | Python | Python3 | py | Accepted | 30 | 5616 | 1,041 | row, col = [True] * 8, [True] * 8
d_pos, d_neg = [True] * 15, [True] * 15
board = [["."] * 8 for _ in range(8)]
def change_state(r: int, c: int, undo: bool = False) -> None:
if undo:
row[r] = col[c] = d_pos[r + c] = d_neg[r - c + 7] = True
board[r][c] = "."
else:
row[r] = col[c] = d_po... | 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,180 |
s485697932 | p02244 | u799595944 | 1583024169 | Python | Python3 | py | Accepted | 50 | 5660 | 1,557 | import itertools
def hand_in_answer(v):
base = [".", ".", ".", ".", ".", ".", ".", "."]
for i in range(8):
tmp = base.copy()
tmp[v[i]] = "Q"
print("".join(tmp))
def ifGoodPosition(position, v):
yo = position[0]
xo = position[1]
x = xo
y = yo
x += 1
y += 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,181 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.