This file contains hidden or 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
| N, M = map(int, input().split()) | |
| C = list(map(int, input().split())) | |
| A = [] | |
| zoo = [[] for _ in range(N)] # i番目の動物園で見ることができる動物 | |
| for i in range(M): | |
| _, *a = list(map(int, input().split())) | |
| a = list(map(lambda x: int(x) - 1, a)) | |
| for j in a: | |
| zoo[j].append(i) |
This file contains hidden or 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
| M = 10**6 + 1 | |
| N, D = map(int, input().split()) | |
| A = list(map(int, input().split())) | |
| cnt = [0] * M | |
| for x in A: | |
| cnt[x] += 1 | |
| if D == 0: | |
| print(sum(max(x - 1, 0) for x in cnt)) | |
| exit() |
This file contains hidden or 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
| from collections import defaultdict | |
| N, M = map(int, input().split()) | |
| d = defaultdict(int) | |
| for _ in range(M): | |
| A, B = map(int, input().split()) | |
| d[(A + B) % N] += 1 | |
| ans = M * (M - 1) // 2 | |
| for _, v in d.items(): | |
| ans -= v * (v - 1) // 2 |
This file contains hidden or 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
| def calc_dp(s): | |
| # dp[i][0] : s[0..i-1] の文字列で、末尾を '.' にした場合の o の最大数 | |
| # dp[i][1] : s[0..i-1] の文字列で、末尾を 'o' にした場合の o の最大数 | |
| dp = [[-float("inf")] * 2 for _ in range(N + 1)] | |
| dp[0][0] = 0 | |
| for i in range(N): | |
| if s[i] != "o": | |
| dp[i + 1][0] = max(dp[i][0], dp[i][1]) | |
| if s[i] != ".": | |
| dp[i + 1][1] = dp[i][0] + 1 |
This file contains hidden or 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
| from collections import deque | |
| H, W = map(int, input().split()) | |
| S = [list(input().strip()) for _ in range(H)] | |
| A, B, C, D = map(lambda x: int(x) - 1, input().split()) | |
| dist = [[float("inf")] * W for _ in range(H)] | |
| dist[A][B] = 0 | |
| dirs = [(0, 1), (1, 0), (0, -1), (-1, 0)] |
This file contains hidden or 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
| def calculate_lcsl(S, T): | |
| s = len(S) | |
| t = len(T) | |
| lcsl = [[0] * (t + 1) for _ in range(s + 1)] | |
| for n in range(s + 1): # 不要 | |
| lcsl[n][0] = 0 | |
| for k in range(t + 1): # 不要 | |
| lcsl[0][k] = 0 | |
| for n in range(1, s + 1): | |
| for k in range(1, t + 1): |
This file contains hidden or 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
| # 実際の選挙結果からドント式を使って当選数を割り当てるスクリプト | |
| # 参議院選挙2025 比例代表 党派別得票数 | |
| A = [ | |
| 12_808_306, # 自民 | |
| 7_620_492, # 国民 | |
| 7_425_053, # 参政 | |
| 7_397_456, # 立民 | |
| 5_210_569, # 公明 | |
| 4_375_926, # 維新 |
This file contains hidden or 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
| #!/bin/bash | |
| # MTS -> mp4 変換スクリプト | |
| for f in *.MTS; do | |
| outfile="${f%.MTS}.mp4" | |
| echo "変換中: $f → $outfile" | |
| ffmpeg -i "$f" \ | |
| -c:v libx264 -preset slow -crf 18 -profile:v high -level 4.0 \ | |
| -c:a aac -b:a 256k -ac 2 \ | |
| -movflags +faststart \ |
This file contains hidden or 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
| import sys | |
| sys.setrecursionlimit(10**9) | |
| class Trie: | |
| ans = 0 | |
| def __init__(self): | |
| self.num = 0 |
This file contains hidden or 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
| N, X = map(int, input().split()) | |
| S = [0] * N | |
| C = [0] * N | |
| P = [0] * N | |
| for i in range(N): | |
| S[i], C[i], P[i] = map(int, input().split()) | |
| P[i] /= 100 | |
| d = [[0.0] * (X + 1) for _ in range(1 << N)] | |
| for x in range(X + 1): | |
| for s in range(1 << N): |
NewerOlder