-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathabc230_c.py
More file actions
281 lines (228 loc) · 6.83 KB
/
Copy pathabc230_c.py
File metadata and controls
281 lines (228 loc) · 6.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
###############################################
###############################################
###############################################
###############################################
[tr3]
N,A,B = map(int,input().split())
P,Q,R,S = map(int,input().split())
for i in range(P,Q+1):
C = []
for j in range(R,S+1):
if abs(i-A)==abs(j-B):
C.append("#")
else:
C.append(".")
print("".join(C))
###############################################
[oto]
N, A, B = map(int, input().split())
P, Q, R, S = map(int, input().split())
P -= 1
Q -= 1
R -= 1
S -= 1
grids: list[list[str]] = []
for i in range(Q - P + 1):
row: list[str] = []
for j in range(S - R + 1):
# 絶対座標
ii = P + i
jj = R + j
# A, Bから見た相対位置
di = ii - (A - 1)
dj = jj - (B - 1)
# print(i, j)
# print(di, dj)
if di == dj:
if max(1 - A, 1 - B) <= di and di <= min(N - A, N - B):
row.append("#")
continue
if di == -dj:
if max(1 - A, B - N) <= di and di <= min(N - A, B - 1):
row.append("#")
continue
row.append(".")
grids.append(row)
for row in grids:
print("".join(row))
print("".join(row))
###############################################
###############################################
###############################################
[gemini,AC]
import sys
input = sys.stdin.read
data = input().split()
N = int(data[0])
A = int(data[1])
B = int(data[2])
P = int(data[3])
Q = int(data[4])
R = int(data[5])
S = int(data[6])
row_len = Q - P + 1
col_len = S - R + 1
output_lines = []
for i in range(row_len):
current_row = P + i
c = ['.'] * col_len
col1 = current_row - (A - B)
if 1 <= col1 <= N:
if R <= col1 <= S:
j = col1 - R
c[j] = '#'
col2 = (A + B) - current_row
if 1 <= col2 <= N:
if R <= col2 <= S:
j = col2 - R
c[j] = '#'
output_lines.append("".join(c))
print('\n'.join(output_lines))
###############################################
[gemini,AC]
import sys
# 標準入力の読み込みを高速化 (微調整)
input = sys.stdin.read
data = input().split()
N = int(data[0])
A = int(data[1])
B = int(data[2])
P = int(data[3])
Q = int(data[4])
R = int(data[5])
S = int(data[6])
# 矩形領域のサイズを計算
row_len = Q - P + 1
col_len = S - R + 1
output_lines = []
# 各行 i (0 <= i < row_len) について処理する
# i は矩形内の行インデックス
for i in range(row_len):
# 矩形内の i 行目は、元のグリッドの P+i 行目にあたる
current_row = P + i
# 行を初期化
c = ['.'] * col_len
# --- 対角線 1 (傾き +1) の交差判定 ---
# 対角線1の式: current_row = col + (A - B)
# これを満たす col は: col = current_row - (A - B)
col1 = current_row - (A - B)
# N x N グリッド内の制約: 1 <= col1 <= N
if 1 <= col1 <= N:
# 矩形領域内の列 R <= col1 <= S に入っているか?
if R <= col1 <= S:
# 矩形内の列インデックス j を計算: j = col1 - R
j = col1 - R
c[j] = '#'
# --- 対角線 2 (傾き -1) の交差判定 ---
# 対角線2の式: current_row = (A + B) - col
# これを満たす col は: col = (A + B) - current_row
col2 = (A + B) - current_row
# N x N グリッド内の制約: 1 <= col2 <= N
if 1 <= col2 <= N:
# 矩形領域内の列 R <= col2 <= S に入っているか?
if R <= col2 <= S:
# 矩形内の列インデックス j を計算: j = col2 - R
j = col2 - R
c[j] = '#'
# 行の結果を出力リストに追加
output_lines.append("".join(c))
# 全ての行をまとめて出力
print('\n'.join(output_lines))
###############################################
###############################################
###############################################
###############################################
[TLE31]
N,A,B=map(int,input().split())
P,Q,R,S=map(int,input().split())
from collections import defaultdict,deque,Counter
cnt = defaultdict(list)
for k in range(max(1-A,1-B),min(N-A,N-B)+1):
if P-1<=A+k-1<Q and R-1<=B+k-1<S:
cnt[A+k-1-(P-1)].append(B+k-1-(R-1))
for k in range(max(1-A,B-N),min(N-A,B-1)+1):
if P-1<=A+k-1<Q and R-1<=B-k-1<S:
cnt[A+k-1-(P-1)].append(B-k-1-(R-1))
#print(cnt)
c0=["."]*(S-(R-1))
for i in range(Q-(P-1)):
c=c0.copy()
lst=cnt[i]
for j in lst:
c[j]='#'
print(''.join(c))
###############################################
[TLE32]
N,A,B=map(int,input().split())
P,Q,R,S=map(int,input().split())
from collections import defaultdict,deque,Counter
cnt = defaultdict(list)
for k in range(max(1-A,1-B),min(N-A,N-B)+1):
if P-1<=A+k-1<Q and R-1<=B+k-1<S:
cnt[A+k-1-(P-1)].append(B+k-1-(R-1))
for k in range(max(1-A,B-N),min(N-A,B-1)+1):
if P-1<=A+k-1<Q and R-1<=B-k-1<S:
cnt[A+k-1-(P-1)].append(B-k-1-(R-1))
#print(cnt)
for i in range(Q-(P-1)):
c=""
lst=cnt[i]
lst.sort()
for j in range(S-(R-1)):
if j in lst:
c+='#'
else:
c+='.'
print(c)
###############################################
[TLE31]
N,A,B=map(int,input().split())
P,Q,R,S=map(int,input().split())
C=[]
for k in range(max(1-A,1-B),min(N-A,N-B)+1):
if P-1<=A+k-1<Q and R-1<=B+k-1<S:
C+=[(A+k-1,B+k-1)]
for k in range(max(1-A,B-N),min(N-A,B-1)+1):
if P-1<=A+k-1<Q and R-1<=B-k-1<S:
C+=[(A+k-1,B-k-1)]
#print(len(C))
C2=[]
for i in range(Q-(P-1)):
C2+=[['.']*(S-(R-1))]
for ci in C:
i0,j0=ci[0],ci[1]
i=i0-(P-1)
j=j0-(R-1)
C2[i][j]='#'
for i in range(len(C2)):
print(''.join(list(C2[i])))
###############################################
###############################################
[claude,TLE31]
N, A, B = map(int, input().split())
P, Q, R, S = map(int, input().split())
# 2次元グリッドを直接初期化
height = Q - P + 1
width = S - R + 1
grid = [['.' for _ in range(width)] for _ in range(height)]
# 対角線1: 右下方向 (A+k, B+k)
for k in range(max(1-A, 1-B), min(N-A, N-B) + 1):
i, j = A + k - 1, B + k - 1
if P - 1 <= i < Q and R - 1 <= j < S:
grid[i - (P - 1)][j - (R - 1)] = '#'
# 対角線2: 右上方向 (A+k, B-k)
for k in range(max(1-A, B-N), min(N-A, B-1) + 1):
i, j = A + k - 1, B - k - 1
if P - 1 <= i < Q and R - 1 <= j < S:
grid[i - (P - 1)][j - (R - 1)] = '#'
# 出力
for row in grid:
print(''.join(row))
###############################################
###############################################
###############################################
###############################################
###############################################
###############################################
###############################################
###############################################