32ä½ 300ç¹
ã´ã¼ã«ãã³ã¦ã£ã¼ã¯ã ã£ãã®ã§AtCoderã«åå
Cåé¡ã¾ã§è§£ããã®ãããã£ãã®ãããããããããããã®é ä½ãã¨ãã
ä»åã¯2人ã²ã¼ã ç³»ã®åé¡ç¸ãã§ãããããã£ã
å ¬å¼ã®è§£èª¬
www.slideshare.net
A: カードと兄妹 - AtCoder Regular Contest 038 | AtCoder
2人ã®ãã¬ã¤ã¤ã¼ãæ°åãæ¸ãããã«ã¼ãã交äºã«åã£ã¦ãã
ãäºãã«åè¨ã®æ°å¤ã大ãããããã¨ããæã«ãå
æ»ã®ãã¬ã¤ã¤ã¼ãå¾ãããåè¨ã¯ããã¤ã«ãªãã
大ããé ã«ã½ã¼ããã¦ä¸ã¤é£ã°ãã§åã£ã¦ããã ã
# -*- coding: utf-8 -*- import math,string,itertools,fractions,heapq,collections,re,array,bisect def n(): return int(raw_input()) def ln(): return map(int, raw_input().strip().split()) n() a = ln() a.sort(reverse=True) s = 0 for i in xrange(0, len(a), 2): s += a[i] print s
B: マス目と駒 - AtCoder Regular Contest 038 | AtCoder
éè¡ã§ãããã©ãããå®ç¾©ãããç¤é¢ãä¸ãããã
ä¸çªå·¦ä¸ã®å°ç¹ã«ã³ããç½®ãã¦ããã¬ã¤ã¤ã¼ã交äºã«å³ãä¸ãå³ä¸ã«åããã¦ãã£ã¦ãåãããªãã£ããã¬ã¤ã¤ã¼ã®è² ãã¨ãªã
ãã¬ã¤ã¤ã¼ãåå©ã«åãã¦æé©ãªæ¦ç¥ãã¨ã£ãæã«å
æã¨å¾æã®ã©ã¡ããåã¤ãçãã
å·¦ãä¸ã«ç§»åãããã¨ã¯ãªãã®ã§ãå³ä¸ããé ã«æ±ºãã¦ãããã¨ãã§ãã
é害ç©ããã£ã¦ç§»åã§ããªãå ´åããããã¯ç¸æãåã¤ãã¨ã確å®ãã¦ãããã¹ã«ãã移åã§ããªãå ´åã«è² ãã確å®ãã
# -*- coding: utf-8 -*- import math,string,itertools,fractions,heapq,collections,re,array,bisect def s(): return raw_input().strip() def ln(): return map(int, raw_input().strip().split()) H, W = ln() board = [[1] * (W + 2) for i in xrange(H + 2)] for i in xrange(H): t = s() for j in xrange(W): if t[j] == '.': board[i + 1][j + 1] = 0 lose = [[0] * (W + 2) for i in xrange(H + 2)] for i in xrange(H, 0, -1): for j in xrange(W, 0, -1): if lose[i + 1][j] == 0 or board[i + 1][j] == 1: if lose[i][j + 1] == 0 or board[i][j + 1] == 1: if lose[i + 1][j + 1] == 0 or board[i + 1][j + 1] == 1: lose[i][j] = 1 print 'First' if lose[1][1] == 0 else 'Second'
C: 茶碗と豆 - AtCoder Regular Contest 038 | AtCoder
100ç¹ã¾ã§ããåããªãã£ã(æ大ã¯104ç¹)
\(N\)åã®è¶ç¢ãä¸ãããã
ããããã®è¶ç¢ã«ã¤ãã¦ãä¸ã«å
¥ã£ã¦ããè±ã®æ°ã¨ãæåã®ä½ååã¾ã§ã®ç¯å²ã®è¶ç¢ã«è±ã移åã§ããããä¸ãããã
2人ã®ãã¬ã¤ã¤ã¼ã交äºã«è±ã1ã¤ãã¤ç§»åãã¦ãã£ãæã«ãè±ã移åã§ããªãã£ããã¬ã¤ã¤ã¼ãè² ãã¨ãªã
å ¸åçãªGrundyæ°ã®åé¡
# -*- coding: utf-8 -*- import math,string,itertools,fractions,heapq,collections,re,array,bisect def n(): return int(raw_input()) def ln(): return map(int, raw_input().strip().split()) N = n() C = [0] A = [0] for i in xrange(N-1): c, a = ln() C.append(c) A.append(a) grundy = [0] * (N) for i in xrange(1, N): for j in xrange(max(i - C[i], 0), i): s.add(grundy[j]) for k in xrange(N): if k not in s: grundy[i] = k break result = 0 for i in xrange(N): for j in xrange(A[i] % 2): result ^= grundy[i] print 'First' if result != 0 else 'Second'