2934 - IP_2023_YOU_FIN Scoreboard

Time

2023/12/26 15:30:00 2023/12/26 18:30:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
14191 Reverse Linked List II
14192 Fill Palindrome
14193 Vigenère Cipher Decoder
14194 Find The Way Out

14191 - Reverse Linked List II   

Description

給定主要執行程式main.c (題號.c)、以及Header檔function.h (題號.h);請試著完成Header檔中未實現的函式:reversBetween()

 

function.h:

ListNode

  • val (int) 儲存的整數

  • next (struct ListNode*) 代表下一個ListNode的記憶體位置

 

Methods:

- struct ListNode *reverseBetween(struct ListNode *head, int left, int right) – 

  • 需不斷的拜訪傳進的ListNode記憶體的下一個ListNode記憶體(next)直至限定範圍right

  • 將範圍介於left, right 間所有拜訪過的ListNode中的下一個記憶體(next)指向上一個拜訪過的ListNode記憶體

  • 將原先位置left的前一個ListNode記憶體的下一個ListNode記憶體(next)指向反轉後的第一個ListNode記憶體(原先位置right的ListNode記憶體)

  • 將反轉後的最後一項ListNode記憶體(原先位置left的ListNode記憶體)的下一個ListNode記憶體(next)指向原位置right的下一個ListNode記憶體,使經過反轉後的所有節點依然為Linked List

  • 最後回傳Linked List的第一個ListNode記憶體。

 

Hint:

  1. 可以透過迴圈和next來不斷拜訪並取得下一個ListNode

  2. 可以宣告四個struct ListNode *dummyNode, *currNode, *nextNode, *prevNode,用以儲存Linked List的第一個ListNode記憶體和將left, right範圍間ListNode記憶體的下一個ListNode記憶體(next)指向上一個拜訪的ListNode記憶體,並持續拜訪下一個ListNode記憶體

 

 

function.c

#include "function.h"

struct ListNode *reverseBetween(struct ListNode *head, int left, int right) {

  // TODO

} 

Input

left right

n1 n2 n3 n4 n5

 

Note:

  1. left, right 代表需做反轉(reverse)的ListNode範圍

  2. 1 <= left <= right <= 5

  3. left = right,則表示不需做反轉

  4. left, right代表Linked List中的第n個ListNode,非Linked List中的ListNode index值

e.g. left: 2, right: 4, Linked List中每個ListNode的val: [1, 2, 3, 4, 5]

       (o) 代表需做反轉的部分為Linked List的[2, 3, 4]

       (x) 代表需做反轉的部分為Linked List的[3, 4, 5]

  1. n1~n5為整數,-2147483648 <= n <= 2147483647

 

Output

輸出符合以下格式:

e.g n1 n4 n3 n2 n5

 

Note:

  1. 無需處理輸出

Sample Input  Download

Sample Output  Download

Partial Judge Code

14191.c

Partial Judge Header

14191.h

Tags




Discuss




14192 - Fill Palindrome   

Description

給定一個字串(稱作string,只含大小寫英文字母),請試著在string字串前方加上最少字母的字串使之成為回文字串

 

Hint:

  1. 使用 <string.h> 中的strlen( ) 判斷給定的字串長度

 

Note: 

  1. 大小寫英文字母不相等

e.g 回文字串:aba / 非回文字串:Aba

 

  1. 字串string可能的情況:

  • string本身即是回文字串:

e.g. string: aa  ->  輸出:aa

 

  • string不是回文字串(可能包含回文字串在內):

e.g. string: ab  ->  輸出:bab

 string: aab -> 輸出:baab

 

 

Input

一個字串*string

 

Note:

  1. 2 <= *string字串的長度 <= 20

  2. *string字串內只含大小寫英文字母(A-Z, a-z)

 

 

Output

輸出必須符合以下格式:

*palindrome    

 

Note:

  1. 輸出的最後必須有一個換行符號 (“\n”)

  2. *palindrome為一回文字串

 

 

Sample Input  Download

Sample Output  Download

Tags




Discuss




14193 - Vigenère Cipher Decoder   

Description

Vigenère Cipher是一個用一系列的Caesar Cipher來加密文字的演算機制;根據一個設定好的keyword,可以透過以下的表格來進行文字的加密以及解密

(Excerpted from wiki: https://en.wikipedia.org/wiki/Vigen%C3%A8re_cipher)

 

舉例:

  • 如果加密過後的文字為LXFOPVEFRNHR,且使用的keyword是LEMON,透過以下步驟可以將文字解密:

  1. 先將keyword的長度複製對應到加密文字的長度

  2. 將加密文字與對應到的keyword進行解密

  3. 解密後即可得出原始未加密的文字

 

Ciphertext: LXFOPVEFRNHR

Keyword: LEMONLEMONLE

Plaintext: ATTACKATDAWN

 

給定一個 keyword字串,和一個加密過後的 text字串;請試著找出原始未加密的文字字串為何


 

給定主要執行程式main.c (題號.c)、以及Header檔function.h (題號.h);請試著完成Header檔中未實現的函式:decrypt()

 

Methods:

- void decrypt(int textLength, char *textPtr, char keyword[21]) – 將傳入參數textLengthtext字串的長度)、 textPtrtext字串的第一個位址的指標)和 keyword ; 找出原始未加密的字串

 

hint:

  1. 可以透過textPtr++來取得下一個元素,並對其修改

 #include "function.h"

void decrypt(int textLength, char *textPtr, char keyword[21]) {

  // TO DO

}

Input

兩個字串 keyword, text,分別代表加密時所需要的keyword和加密過後的字串

 

Note:

  1. keywordtext只包含大寫的英文字母

  2. 1 <= keyword字串的長度 <= 20;1 <= text字串的長度 <= 600

  3. 無需處理輸入

Output

輸出比須符合以下格式:

PT

 

Note:

  1. 無需處理輸出

Sample Input  Download

Sample Output  Download

Partial Judge Code

14193.c

Partial Judge Header

14193.h

Tags




Discuss




14194 - Find The Way Out   

Description

給定一個5*5的二維陣列(稱作map),map中只會有’-’, ‘x’, ‘P’三者,分別代表「可走的路」、「不可走的路」、「人的位置」,請試著找出’P’)走到map最右上位置(map[0][4])的路徑。

 

Note:

  1. 人(’P’)的位置必在map左下角(map[4][0]

  2. 移動規則:若可以同時向右或向上移動則向右優先,向上次之(移動方向只會有「向右」、「向上」,不會出現「向左」、「向下」的情況)

說明:若無法向右,則向上

無法向右的情況:

  • 超過地圖邊界

- - - - -

- - - - P

- - - - -

- - - - -

- - - - -

 

  • 右邊為不可走的路

- - - - -

- - - - -

- - - - -

- - P x -

- - - - -

 

  • 右邊為死路(向右後的下一步無法向右和向上)

- - - - -

- - - - -

- - x - -

- P - x -

- - - - -

 

Input

map

 

Note:

  1. map為5*5的二維陣列,其中只會有’-’, ‘x’, ‘P’ 三者其一

 

Output

輸出比須符合以下格式:

stepRecord

    

 

Note:

  1. 輸出的最後必須有一個換行符號 (“\n”)

  2. stepRecord為字串,紀錄人(’P’)到map[0][4] 的路徑

  3. 字串stepRecord 中只會有’R’, ‘U’,分別代表「向右」、「向上」

Sample Input  Download

Sample Output  Download

Tags




Discuss