Submission #3604788
Source Code Expand
local n = 4 local wordTb = {} local hashValTb = {} local maxSize = n local function getHashVal(str) local hash = 0 for i=1, string.len(str) do local charN = string.byte(str,i) hash = 33*hash + charN end return hash % (maxSize+2) end local function checkWord(recordTb, word) if not next(recordTb) then return end local val = getHashVal(word) if hashValTb[val] then return false end hashValTb[val] = true local lastWord = recordTb[#recordTb] return string.byte(lastWord,#lastWord) == string.byte(word,1) end for i=1, n do local input = io.read("*n") local p = string.find(input, "/n") local word = string.sub(input, p) local ret = checkWord(wordTb, word) if not ret then return "NO" end wordTb[i] = word end return "YES"
Submission Info
Submission Time | |
---|---|
Task | B - Shiritori |
User | vjudge5 |
Language | Bash (GNU bash v4.3.11) |
Score | 0 |
Code Size | 744 Byte |
Status | RE |
Exec Time | 2 ms |
Memory | 376 KB |
Judge Result
Set Name | All | Sample | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 200 | 0 / 0 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
All | max_1, max_2, max_3, max_4, min_1, no1_1, no1_2, no2_1, no2_2, random_1, random_2, sample_01, sample_02, sample_03, sample_04, yes_1, yes_2 |
Sample | sample_01, sample_02, sample_03, sample_04 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
max_1 | RE | 2 ms | 376 KB |
max_2 | RE | 2 ms | 376 KB |
max_3 | RE | 2 ms | 376 KB |
max_4 | RE | 2 ms | 376 KB |
min_1 | RE | 2 ms | 376 KB |
no1_1 | RE | 2 ms | 376 KB |
no1_2 | RE | 2 ms | 376 KB |
no2_1 | RE | 2 ms | 376 KB |
no2_2 | RE | 2 ms | 376 KB |
random_1 | RE | 2 ms | 376 KB |
random_2 | RE | 2 ms | 376 KB |
sample_01 | RE | 2 ms | 376 KB |
sample_02 | RE | 2 ms | 376 KB |
sample_03 | RE | 2 ms | 376 KB |
sample_04 | RE | 2 ms | 376 KB |
yes_1 | RE | 2 ms | 376 KB |
yes_2 | RE | 2 ms | 376 KB |