diff --git "a/\352\267\270\353\236\230\355\224\204/P1325_\355\232\250\354\234\250\354\240\201\354\235\270\355\225\264\355\202\271.py" "b/\352\267\270\353\236\230\355\224\204/P1325_\355\232\250\354\234\250\354\240\201\354\235\270\355\225\264\355\202\271.py" index 5edebdf..7b0f15f 100644 --- "a/\352\267\270\353\236\230\355\224\204/P1325_\355\232\250\354\234\250\354\240\201\354\235\270\355\225\264\355\202\271.py" +++ "b/\352\267\270\353\236\230\355\224\204/P1325_\355\232\250\354\234\250\354\240\201\354\235\270\355\225\264\355\202\271.py" @@ -7,6 +7,7 @@ def BFS(v): + visited = [False] * (N + 1) queue = deque() queue.append(v) visited[v] = True @@ -19,18 +20,14 @@ def BFS(v): queue.append(i) -for _ in range(M): +for i in range(M): S, E = map(int, input().split()) A[S].append(E) for i in range(1, N + 1): # 모든 노드에서 BFS 실행 - visited = [False] * (N + 1) BFS(i) -maxVal = 0 -for i in range(1, N + 1): - maxVal = max(maxVal, answer[i]) - +maxVal = max(answer) for i in range(1, N + 1): if maxVal == answer[i]: print(i, end=' ') diff --git "a/\354\236\220\353\243\214\352\265\254\354\241\260/P17298_\354\230\244\355\201\260\354\210\230.py" "b/\354\236\220\353\243\214\352\265\254\354\241\260/P17298_\354\230\244\355\201\260\354\210\230.py" index 9657e39..1be10f2 100644 --- "a/\354\236\220\353\243\214\352\265\254\354\241\260/P17298_\354\230\244\355\201\260\354\210\230.py" +++ "b/\354\236\220\353\243\214\352\265\254\354\241\260/P17298_\354\230\244\355\201\260\354\210\230.py" @@ -1,3 +1,4 @@ +import sys n = int(input()) ans = [0] * n A = list(map(int, input().split())) diff --git "a/\354\236\220\353\243\214\352\265\254\354\241\260/P1874_\354\212\244\355\203\235\354\210\230\354\227\264.py" "b/\354\236\220\353\243\214\352\265\254\354\241\260/P1874_\354\212\244\355\203\235\354\210\230\354\227\264.py" index dfdf34c..5e73e58 100644 --- "a/\354\236\220\353\243\214\352\265\254\354\241\260/P1874_\354\212\244\355\203\235\354\210\230\354\227\264.py" +++ "b/\354\236\220\353\243\214\352\265\254\354\241\260/P1874_\354\212\244\355\203\235\354\210\230\354\227\264.py" @@ -1,30 +1,28 @@ -N = int(input()) +N = int(input()); A = [0]*N for i in range(N): - A[i] = int(input()) + A[i] = int(input()); stack = [] num = 1 result = True -answer = "" +answer = [] for i in range(N): su = A[i] - if su >= num: #현재 수열 값 >= 오름차순 자연수: 값이 같아질 때까지 push() 수행 + if su >= num: while su >= num: stack.append(num) - num += 1 - answer += "+\n" + num+=1 + answer.append('+') stack.pop() - answer += "-\n" - else: #현재 수열 값 < 오름차순 자연수: pop()을 수행해 수열 원소를 꺼냄 + answer.append('-') + else: n = stack.pop() - if n > su: #스택의 가장 위의 수가 만들어야 하는 수열의 수보다 크면 수열을 출력할 수 없음 + if n > su: print("NO") result = False break else: - answer += "-\n" + answer.append('-') if result: - print(answer) - - - + for i in answer: + print(i) diff --git "a/\354\240\225\353\240\254/P1377_\353\262\204\353\270\224\354\206\214\355\212\2701.py" "b/\354\240\225\353\240\254/P1377_\353\262\204\353\270\224\354\240\225\353\240\2541.py" similarity index 95% rename from "\354\240\225\353\240\254/P1377_\353\262\204\353\270\224\354\206\214\355\212\2701.py" rename to "\354\240\225\353\240\254/P1377_\353\262\204\353\270\224\354\240\225\353\240\2541.py" index 406b09b..a4a0d93 100644 --- "a/\354\240\225\353\240\254/P1377_\353\262\204\353\270\224\354\206\214\355\212\2701.py" +++ "b/\354\240\225\353\240\254/P1377_\353\262\204\353\270\224\354\240\225\353\240\2541.py" @@ -10,4 +10,4 @@ for i in range(N): if Max < sorted_A[i][1] - i: # 정렬 전 index - 정렬 후 index 계산의 최댓값 저장하기 Max = sorted_A[i][1] - i -print(Max + 1) \ No newline at end of file +print(Max + 1) diff --git "a/\354\240\225\353\240\254/P1517_\353\262\204\353\270\224\354\206\214\355\212\2702.py" "b/\354\240\225\353\240\254/P1517_\353\262\204\353\270\224\354\240\225\353\240\2542.py" similarity index 100% rename from "\354\240\225\353\240\254/P1517_\353\262\204\353\270\224\354\206\214\355\212\2702.py" rename to "\354\240\225\353\240\254/P1517_\353\262\204\353\270\224\354\240\225\353\240\2542.py" diff --git "a/\355\203\220\354\203\211/P1206_DFS\354\231\200BFS.py" "b/\355\203\220\354\203\211/P1260_DFS\354\231\200BFS.py" similarity index 100% rename from "\355\203\220\354\203\211/P1206_DFS\354\231\200BFS.py" rename to "\355\203\220\354\203\211/P1260_DFS\354\231\200BFS.py"