-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
37da807
commit 365e1bb
Showing
7 changed files
with
130 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import sys | ||
input = sys.stdin.readline | ||
|
||
N, L = map(int, input().split()) | ||
|
||
# 일단 포기 ^^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import sys | ||
input = sys.stdin.readline | ||
|
||
result = 0 | ||
|
||
def z(n, x, y): | ||
global result | ||
if x == r and y == c: | ||
print(result) | ||
exit(0) | ||
|
||
if n == 1: | ||
result += 1 | ||
return | ||
|
||
if not (x<=r<x+n and y<=c<y+n): | ||
result += n*n | ||
return | ||
|
||
z(n/2, x, y) | ||
z(n/2, x, y+n/2) | ||
z(n/2, x+n/2, y) | ||
z(n/2, x+n/2, y+n/2) | ||
|
||
n, r, c = map(int, input().split()) | ||
z(2**n, 0, 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import sys | ||
input = sys.stdin.readline | ||
|
||
n, r, c = map(int, input().split()) | ||
|
||
# n: 변의 길이,x: 현재 위치의 x축 값, y:현재 위치의 y축 값 | ||
result = 0 | ||
def N(n, x, y): | ||
global result | ||
|
||
if x==r and y==c: | ||
print(int(result)) | ||
exit(0) | ||
|
||
if n == 1: | ||
result += 1 | ||
return | ||
|
||
if not(x<=r<x+n and y<=c<y+n): | ||
result += n*n | ||
return | ||
|
||
# 1사분면 | ||
N(n/2, x, y) | ||
# 2사분면 | ||
N(n/2, x, y+n/2) | ||
# 3사분면 | ||
N(n/2, x+n/2, y) | ||
# 4사분면 | ||
N(n/2, x+n/2, y+n/2) | ||
|
||
N(2**n, 0, 0) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import sys | ||
input = sys.stdin.readline | ||
|
||
arr = [] | ||
while True: | ||
val = input().rstrip() | ||
if int(val) == 0: | ||
break | ||
arr.append(list(map(int, val))) | ||
|
||
for a in arr: | ||
flag = 1 | ||
if len(a)%2==0: | ||
while a: | ||
if a.pop() == a.pop(0): | ||
flag *= 1 | ||
else: | ||
flag *= 0 | ||
else: | ||
while len(a)>1: | ||
if a.pop() == a.pop(0): | ||
flag *= 1 | ||
else: | ||
flag *= 0 | ||
if flag == 1: | ||
print('yes') | ||
else: | ||
print('no') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import sys | ||
input = sys.stdin.readline | ||
|
||
N = int(input()) | ||
arr = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import sys | ||
input = sys.stdin.readline | ||
t, w = map(int, input().split()) | ||
A = [int(input()) for _ in range(t)] | ||
dp = [[0]*(t+1) for _ in range(w+1)] | ||
|
||
for row in range(w+1): | ||
for col in range(1, t+1): | ||
print(row, col) | ||
c = 1 if A[col - 1] == row % 2 + 1 else 0 | ||
if row ==0: | ||
dp[row][col] = dp[row][col-1]+ c | ||
continue | ||
dp[row][col] = max(dp[row-1][col-1], dp[row][col-1]) + c | ||
|
||
print(max([row[-1] for row in dp])) |