結果
問題 | No.1506 Unbalanced Pocky Game |
ユーザー | magurofly |
提出日時 | 2021-05-14 22:23:59 |
言語 | Ruby (3.3.0) |
結果 |
AC
|
実行時間 | 165 ms / 2,000 ms |
コード長 | 4,292 bytes |
コンパイル時間 | 461 ms |
コンパイル使用メモリ | 7,808 KB |
実行使用メモリ | 25,856 KB |
最終ジャッジ日時 | 2024-10-02 02:00:08 |
合計ジャッジ時間 | 10,101 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 84 ms
12,160 KB |
testcase_01 | AC | 90 ms
12,160 KB |
testcase_02 | AC | 89 ms
12,032 KB |
testcase_03 | AC | 91 ms
12,672 KB |
testcase_04 | AC | 136 ms
19,456 KB |
testcase_05 | AC | 141 ms
20,736 KB |
testcase_06 | AC | 131 ms
17,280 KB |
testcase_07 | AC | 115 ms
15,872 KB |
testcase_08 | AC | 129 ms
17,792 KB |
testcase_09 | AC | 147 ms
20,992 KB |
testcase_10 | AC | 144 ms
21,120 KB |
testcase_11 | AC | 113 ms
16,512 KB |
testcase_12 | AC | 108 ms
15,232 KB |
testcase_13 | AC | 98 ms
13,440 KB |
testcase_14 | AC | 117 ms
16,000 KB |
testcase_15 | AC | 112 ms
14,976 KB |
testcase_16 | AC | 150 ms
20,992 KB |
testcase_17 | AC | 119 ms
16,640 KB |
testcase_18 | AC | 106 ms
14,720 KB |
testcase_19 | AC | 101 ms
13,952 KB |
testcase_20 | AC | 137 ms
20,992 KB |
testcase_21 | AC | 108 ms
15,360 KB |
testcase_22 | AC | 123 ms
17,920 KB |
testcase_23 | AC | 87 ms
12,288 KB |
testcase_24 | AC | 86 ms
12,160 KB |
testcase_25 | AC | 162 ms
25,856 KB |
testcase_26 | AC | 165 ms
24,960 KB |
testcase_27 | AC | 165 ms
25,088 KB |
testcase_28 | AC | 164 ms
24,448 KB |
testcase_29 | AC | 161 ms
24,960 KB |
testcase_30 | AC | 163 ms
25,344 KB |
testcase_31 | AC | 162 ms
25,216 KB |
testcase_32 | AC | 160 ms
24,832 KB |
testcase_33 | AC | 165 ms
24,960 KB |
testcase_34 | AC | 163 ms
24,448 KB |
testcase_35 | AC | 160 ms
24,704 KB |
testcase_36 | AC | 95 ms
12,416 KB |
testcase_37 | AC | 86 ms
12,160 KB |
testcase_38 | AC | 87 ms
12,032 KB |
testcase_39 | AC | 88 ms
12,288 KB |
testcase_40 | AC | 85 ms
12,416 KB |
testcase_41 | AC | 89 ms
12,416 KB |
testcase_42 | AC | 91 ms
12,288 KB |
testcase_43 | AC | 89 ms
12,160 KB |
testcase_44 | AC | 90 ms
12,160 KB |
testcase_45 | AC | 88 ms
12,160 KB |
testcase_46 | AC | 121 ms
16,768 KB |
testcase_47 | AC | 97 ms
13,440 KB |
testcase_48 | AC | 98 ms
13,824 KB |
testcase_49 | AC | 119 ms
17,280 KB |
testcase_50 | AC | 118 ms
16,768 KB |
testcase_51 | AC | 122 ms
17,408 KB |
testcase_52 | AC | 114 ms
16,256 KB |
testcase_53 | AC | 125 ms
18,304 KB |
testcase_54 | AC | 98 ms
13,952 KB |
testcase_55 | AC | 96 ms
13,440 KB |
testcase_56 | AC | 96 ms
13,440 KB |
testcase_57 | AC | 117 ms
16,896 KB |
testcase_58 | AC | 97 ms
13,184 KB |
testcase_59 | AC | 94 ms
12,800 KB |
testcase_60 | AC | 103 ms
14,848 KB |
testcase_61 | AC | 114 ms
16,512 KB |
testcase_62 | AC | 105 ms
15,616 KB |
testcase_63 | AC | 101 ms
14,592 KB |
testcase_64 | AC | 119 ms
17,408 KB |
testcase_65 | AC | 100 ms
14,976 KB |
コンパイルメッセージ
Syntax OK
ソースコード
def main @N = int @A = ints if @N == 1 yes elsif @A[-1] > 1 yes else trailing_ones = 0 i = @N - 1 while i > 0 and @A[i] == 1 trailing_ones += 1 i -= 1 end yesno trailing_ones.even? end end DEBUG = true MOD = 10**9+7 YESNO = %w(Bob Alice) INF = 10**9 def int; gets.to_s.to_i end def ints; gets.to_s.split.map { |s| s.to_i } end def int1s; gets.to_s.split.map { |s| s.to_i - 1 } end def intss(n); Array.new(n) { ints }; end def float; gets.to_s.to_f end def floats; gets.to_s.split.map { |s| s.to_f } end def array_of(&convert); gets.to_s.split.map(&convert) end def string; gets.to_s.chomp end def rep(n, &b); Array.new(n, &b) end def yes; puts YESNO[1] end def no; puts YESNO[0] end def yesno t; puts YESNO[t] end def zip(xs, *yss); Enumerator.new { |y| xs.zip(*yss) { |a| y.yield(*a) } } end def max(*xs, &block); block_given? ? xs.max_by(&block) : xs.max end def min(*xs, &block); block_given? ? xs.min_by(&block) : xs.min end def minmax(*xs, &block); block_given? ? xs.minmax_by(&block) : xs.minmax end def gcd(*xs); xs.inject(0, :gcd) end def matrix(h, w, fill=nil, &block); return Array.new(h) { Array.new(w, &block) } if block_given?; Array.new(h) { [fill] * w } end def debug(x = nil); STDERR.puts (block_given? ? yield(x) : x).inspect if DEBUG; x end def debug_grid(grid, width = 1); grid.each { |row| STDERR.puts row.map { |x| x.inspect.ljust(width) }.join("") } if DEBUG; grid end def if_debug; yield if DEBUG end module Boolean def coerce(other); [other, to_i] end def +@; to_i end def to_int; to_i end def *(other); to_i * other end end class TrueClass include Boolean def to_i; 1 end end class FalseClass include Boolean def to_i; 0 end end class Integer def div_ceil(y); (self + y - 1) / y end def mod_inv(mod = MOD); pow(mod-2, mod) end def mod_div(y, mod = MOD); self * mod_inv(y, mod) % mod end def factorial(mod = MOD); (2..self).inject(1) { |f, x| f * x % mod } end def popcount; x = self; c = 0; while x > 0; c += 1 if x & 1 == 1; x >>= 1 end; c end #TODO: faster def bitbrute(&block); (1<<self).times(&block) end def nCr(r); x = 1; (1..r).each { |i| x *= self + 1 - i; x /= i }; x; end def each_divisor; return Enumerator.new { |y| each_divisor { |k| y << k } } unless block_given?; k = 1; while k * k < self; if self % k == 0; yield k; yield self / k end; k += 1; end; yield k if k * k == self end def divisors; each_divisor.to_a end end class Range def end_open; exclude_end? ? self.end : self.end + 1 end def end_close; exclude_end? ? self.end - 1 : self.end end def upper_bound; ac, wa = self.begin, self.end_open; while wa - ac > 1; if yield((wj = (ac + wa) / 2)); ac = wj else wa = wj end; end; yield(ac) ? ac : nil end def lower_bound; ac, wa = self.end_open, self.begin; while ac - wa > 1; if yield((wj = (ac + wa) / 2)); ac = wj else wa = wj end; end; yield(ac) ? ac : nil end def shakutori(r2, &pred); Enumerator.new { |y| j, r = r2.begin, r2.end_open; each { |i| j += 1 while j + 1 < r and pred[i, j+1]; y.yield(i, j) } }; end def widest(&block); Enumerator.new { |y| j, n = self.begin, self.end_open; each { |i| j += 1 while j < n and block[i, j]; y.yield(i, j) if block[i, j] } } end def pairs; Enumerator.new { |y| l, r = self.begin, self.end_open; i = l; while i < r - 1; j = i + 1; while j < r; y.yield(i, j); j += 1 end; i += 1 end } end end class Array def power(&block); (0 ... 1 << size).each(&block) end def sorted_merge(other); a = []; i = j = 0; n, m = size, other.size; if j < m and other[j] < self[i]; a << other[j]; j += 1 else; a << self[i]; i += 1 end while i < n; a.push(*other[j..-1]) if j < m; a end def upper_bound; ac, wa = 0, size; while wa - ac > 1; if yield(self[(wj = (ac + wa) / 2)]); ac = wj else; wa = wj end; end; ac end def lower_bound; ac, wa = size, 0; while wa - ac > 1; if yield(self[(wj = (ac + wa) / 2)]); ac = wj else; wa = wj end; end; ac end def cum(*xs, &op); a = []; a << xs[0] if xs.size > 0; a << x = self[0]; (1...size).each { |i| a << x = op[x, self[i]] }; a end def cumdiff(range); self[range.end_open] - self[range.begin]; end end module Enumerable def sorted_uniq; x = nil; filter { |y| c = x === y; x = y; !c } end def cumsum; ys = [0]; each { |x| ys << x + ys[-1] }; ys end end main