結果

問題 No.714 回転寿司屋のシミュレート
ユーザー mai
提出日時 2017-04-14 23:12:20
言語 Ruby
(3.4.1)
結果
WA  
実行時間 -
コード長 1,974 bytes
コンパイル時間 231 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,544 KB
最終ジャッジ日時 2024-10-09 05:23:23
合計ジャッジ時間 4,574 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 35
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

# 
# フォーマットチェック用🍣
# 
# フォーマットが正しいとWrongAnswerになる.
# 不適合ならRuntimeErrorになる.
# 

# このプログラムで見ないところ(別提出で検査済み)
# ・座席のダブルブッキング


line = gets.chomp!
abort "line 1: format" unless line=~/^\d+$/
numberOfQuery = line.to_i
abort "line 1: 2 <= numberOfQuery <= 5005" unless 2 <= numberOfQuery && numberOfQuery <= 5005

sushineta = {}

numberOfQuery.times{|lineNo|
    line = gets.chomp!
    abort "line #{lineNo+2}: end of line" unless line 
    abort "line #{lineNo+2}: format" unless line=~/^\S+.+\S+$/
    list = line.split
    type = list.shift
    case type
    when '0'
        abort "line #{lineNo+2}: size of parameters(nm)" unless 2 <= list.size
        n = list.shift.to_i # 座る座席
        m = list.shift.to_i # a number of 🍣
        
        abort "line #{lineNo+2}: size of parameters(sushi)" unless m == list.size
        abort "line #{lineNo+2}: 1 <= n <= 20" unless 1 <= n && n <= 20
        abort "line #{lineNo+2}: 0 <= m <= 10" unless 0 <= m && m <= 10
        
        list.each{|sushi|
            abort "line #{lineNo+2}: 寿司ネタはアルファベット表記で記述され最大15文字" unless sushi.size <= 15
            sushineta[sushi] = true
        }
    when '1'
        abort "line #{lineNo+2}: size of parameters" unless 1 == list.size
        sushi = list.shift
        sushineta[sushi] = true
        abort "line #{lineNo+2}: 寿司ネタはアルファベット表記で記述され最大15文字" unless sushi.size <= 15
    when '2'
        abort "line #{lineNo+2}: size of parameters" unless 1 == list.size
        n = list.shift.to_i
        abort "line #{lineNo+2}: 1 <= n <= 20" unless 1 <= n && n <= 20
    else
        abort "line #{lineNo+2}: unknown data type"
    end
}

abort "line **: too many lines" unless !gets
abort "line **: too many kind of sushi " unless sushineta.size <= 53
0