注意事項 一 本比賽系統採用 PC 2, 所使用的 I/O 是標準輸出輸入裝置, 所以可以使用 C 語言的 scanf ( ) printf ( ), 或是 C++ 語言上的 cin cout 來讀入及輸出資料, 比較要注意的是 : 本系統並不是用人工方式來 keyin 資料, 所以不必在意使用者界

Similar documents
1

注意事項 一 本比賽系統採用 PC, 所使用的 I/O 是標準輸出輸入裝置, 所以可以使用 C 語言的 scanf ( ) printf ( ), 或是 C++ 語言上的 cin cout 來讀入及輸出資料, 比較要注意的是 : 本系統並不是用人工方式來 keyin 資料, 所以不必在意使用者界面的

CC213

C/C++ - 字符输入输出和字符确认

C 1 # include <stdio.h> 2 int main ( void ) { 4 int cases, i; 5 long long a, b; 6 scanf ("%d", & cases ); 7 for (i = 0;i < cases ;i ++) 8 { 9

C/C++ - 文件IO

BC04 Module_antenna__ doc

C/C++程序设计 - 字符串与格式化输入/输出

C/C++语言 - C/C++数据

C/C++ - 函数

Spyder Anaconda Spyder Python Spyder Python Spyder Spyder Spyder 開始 \ 所有程式 \ Anaconda3 (64-bit) \ Spyder Spyder IPython Python IPython Sp

投影片 1

2013 C 1 #include <stdio.h> 2 int main(void) 3 { 4 int cases, i; 5 long long a, b; 6 scanf("%d", &cases); 7 for (i = 0; i < cases; i++) 8 { 9 scanf("%

GCSE Mathematics Question Paper Unit 2 March 2012

穨control.PDF

Microsoft Word - 09.數學 docx

C/C++语言 - 运算符、表达式和语句

PowerPoint Presentation

2013 C 1 # include <stdio.h> 2 int main ( void ) 3 { 4 int cases, a, b, i; 5 scanf ("%d", & cases ); 6 for (i = 0;i < cases ;i ++) 7 { 8 scanf ("%d %d

Microsoft Word - template.doc

Microsoft PowerPoint - C_Structure.ppt

C/C++ 语言 - 循环

參 加 第 二 次 pesta 的 我, 在 是 次 交 流 營 上 除 了, 與 兩 年 沒 有 見 面 的 朋 友 再 次 相 聚, 加 深 友 誼 外, 更 獲 得 與 上 屆 不 同 的 體 驗 和 經 歴 比 較 起 香 港 和 馬 來 西 亞 的 活 動 模 式, 確 是 有 不 同 特

WWW PHP

Microsoft Word - HC20138_2010.doc

Gerotor Motors Series Dimensions A,B C T L L G1/2 M G1/ A 4 C H4 E

CC213

Serial ATA ( Silicon Image SiI3114)...2 (1) SATA... 2 (2) B I O S S A T A... 3 (3) RAID BIOS RAID... 5 (4) S A T A... 8 (5) S A T A... 10

Untitled-3

coverage2.ppt

Chn 116 Neh.d.01.nis

3.1 num = 3 ch = 'C' 2

untitled

LEETCODE leetcode.com 一 个 在 线 编 程 网 站, 收 集 了 IT 公 司 的 面 试 题, 包 括 算 法, 数 据 库 和 shell 算 法 题 支 持 多 种 语 言, 包 括 C, C++, Java, Python 等 2015 年 3 月 份 加 入 了 R

Microsoft Word - ChineseSATII .doc

LSC操作说明

<4D F736F F D205F FB942A5CEA668B443C5E9BB73A740B5D8A4E5B8C9A552B1D0A7F75FA6BFB1A4ACFC2E646F63>

SHIMPO_表1-表4

SHIMPO_表1-表4

Chapter 24 DC Battery Sizing

C C

When the rejection rule for a test at every level α can be re-written as then xxx is the p-value of the test. xxx < α, If p-value < α, then the test c

Front 2 Polar F11 ( ) : Polar F11 Polar F11 Polar F11 Polar (Keeps U Fit - Own Workout Program) Polar Polar F11 Polar F11 Polar F11 Polar (

4. 每 组 学 生 将 写 有 习 语 和 含 义 的 两 组 卡 片 分 别 洗 牌, 将 顺 序 打 乱, 然 后 将 两 组 卡 片 反 面 朝 上 置 于 课 桌 上 5. 学 生 依 次 从 两 组 卡 片 中 各 抽 取 一 张, 展 示 给 小 组 成 员, 并 大 声 朗 读 卡

<4D F736F F F696E74202D20B5DAD2BBD5C228B4F2D3A1B0E6292E BBCE6C8DDC4A3CABD5D>

0 0 = 1 0 = 0 1 = = 1 1 = 0 0 = 1

構 築 4 列 牌 陣 從 剩 餘 的 牌 庫 頂 抽 4 張 牌, 面 朝 上 排 列 在 桌 子 中 央 這 4 張 牌 就 是 牌 陣 的 起 始 牌, 包 括 這 張 起 始 牌 在 內, 每 一 列 最 多 只 能 容 納 5 張 牌 將 剩 餘 的 牌 暫 時 置 於 一 旁, 在 下

2015年4月11日雅思阅读预测机经(新东方版)

PowerPoint Presentation

Microsoft Word - CPE考生使用手冊 docx

ch_code_infoaccess

<4D F736F F D DA5BFA6A1C476C1C92DBEC7ACECB8D5A8F728B57BB35D292E646F63>

Important Notice SUNPLUS TECHNOLOGY CO. reserves the right to change this documentation without prior notice. Information provided by SUNPLUS TECHNOLO

Computer Architecture

Microsoft PowerPoint - ryz_030708_pwo.ppt

中国科学技术大学学位论文模板示例文档

Microsoft PowerPoint - Lecture7II.ppt

C

<4D F736F F D20B6B3AA4CBFA43938A67EABD7BAEBB669B1D0AE76BDD2B0F3B1D0BEC7AFE0A44FAD5EBB79B1D0AED72E646F63>

稻江科技暨管理學院

Python a p p l e b e a r c Fruit Animal a p p l e b e a r c 2-2

K7VT2_QIG_v3

CHAPTER VC#

SuperMap 系列产品介绍

Introduction to Hamilton-Jacobi Equations and Periodic Homogenization


WinMDI 28

Microsoft Word - CX VMCO 3 easy step v1.doc

Microsoft PowerPoint - STU_EC_Ch08.ppt

Preface This guide is intended to standardize the use of the WeChat brand and ensure the brand's integrity and consistency. The guide applies to all d

考試學刊第10期-內文.indd

The Development of Color Constancy and Calibration System

MATLAB 1

VASP应用运行优化

Guide to Install SATA Hard Disks

一 課 後 社 團 名 稱 :B02. 直 排 輪 校 隊 C 班 ( 校 隊 班 ) 二 授 課 教 師 : 劉 輔 人 助 教 : 杜 翊 嘉 世 界 盃 滑 輪 溜 冰 錦 標 賽 世 界 冠 軍 榮 獲 VOUGE 時 尚 雜 誌 專 訪 同 週 一 校 隊 班 介 紹

Gerolor Motors Series Dimensions A,B C T L L G1/2 M8 G1/ A 4 C H4 E

EK-STM32F

FILTRON 1. DC AC AC 220V 50HZ / / / / 4. 1) / DC AC FILTRON DC AC FILTRON DC 12V 12VDC D

Microsoft PowerPoint - CH 04 Techniques of Circuit Analysis

Captive Screws Styled knob series M3 thread size Smooth knob meets UL-1950 Designed for hand operation Spring ejected Wide variety of sizes, re

目录 CONTENTS

QQGQ2.E Power Supplies, Information Technology Equipment Including Ele... 1/10

國家圖書館典藏電子全文

Process Data flow Data store External entity 6-10 Context diagram Level 0 diagram Level 1 diagram Level 2 diagram

(Microsoft PowerPoint A UPEC IR ppt \(cn\) \(NDR\)4.8 [\317\340\310\335\304\243\312\275])

Learning Java

WTO

C/C++ - 字符串与字符串函数

Transcription:

注意事項 一 本比賽系統採用 PC 2, 所使用的 I/O 是標準輸出輸入裝置, 所以可以使用 C 語言的 scanf ( ) printf ( ), 或是 C++ 語言上的 cin cout 來讀入及輸出資料, 比較要注意的是 : 本系統並不是用人工方式來 keyin 資料, 所以不必在意使用者界面的問題, 也就是說不用印出像是 "Please enter a number" 或 "The answer is"... 之類的文字 ; 此外, 有些題目是以讀到 EOF 為 input 結束, 有些是讀入 0 結束等等的, 必需善用 I/O 函式 上傳檔案的檔名請勿使用中文以免發生不必要的錯誤 二 比賽用的編譯器版本 :gcc 3.4.4 g++ 3.4.4 jdk 1.6.0_23 Microsoft (R) Visual C# 2010 Compiler version 4.0.30319.1 Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 若出現 Compilation Error, 可能是某些函式不支援 三 PC 2 系統判定錯誤可能原因 : 正確答案錯誤答案 多空白 假設題目 要求結尾有 換行字元 多換行字元 結尾沒有 換行字元 特別注意題目範例是否有換行字元 四 PC 2 系統判定結果說明 : 結果 說明 Yes 解題正確 No - Compilation Error 錯誤 : 編譯錯誤 No - Run-time Error 錯誤 : 程序運行錯誤 No - Time-limit Exceeded 錯誤 : 運行超時 ( 每道題都有運行時間限制 ) No - Wrong Answer 錯誤 : 運行結果與標準答案不一致 No - Excessive Output 錯誤 : 程序運行佔用內存空間超出要求 No - Output Format Error 錯誤 : 輸出格式錯誤 No - Other - Contact Staff 未知錯誤

Problem 1. Min-Heap (Time Limit: 5 seconds) 問題描述 : Heap 基本上分成兩種, 一種是 min-heap, 另一種是 max-heap, heap 最大的特色是, 任一節點恆小 / 大於子節點 由於 heap 必須符合完整二元樹的特性, 因此我們可以利用陣列來實作 heap 向上調整 向下調整 向上調整 : 以 min-heap 來說, 一個節點與其父節點做比較, 若小於父節點便與其交換, 直到 root 為止 向下調整 : 以 min-heap 來說, 與其較小的子節點比較, 如果大於較小的子節點, 即交換不斷地遞迴, 直到其小於子節點或是樹葉為止 本題利用陣列製作一最小堆積 (Min-heap) 並設計以下動作 : (a) insert(k) : 將 k 值放置於 heap 中最後一個位置, 再向上調整至適當的位置 (b) delete-min() : 刪除最小值, 在 min-heap 中最小值即為 root 的值, 刪除 root 之後, 向下調整, 若陣列為空, 則顯示 The min-heap is empty with size = 0. (c) print : 請依序印出陣列之中所有的內容 輸入說明 : 程式提供的選單如下 (a) insert(k) : 將 k 插入並印出, The min-heap is of size currentposition and the current minimum is min-num (b) delete-min() : 刪除最小值, 並印出 The min-heap is of size currentposition and the current minimum is min-num (c) print : 請依序印出陣列之中所有的內容 (d) exit 若輸入 a 10 a 3 a 8 b c, 則表示插入 10, 插入 3, 插入 8, 刪除最小值, 印 出陣列中所有的內容, 指令請以小寫字母表示, 以空白作為間隔, 指令數目 1 < n < 1000,k 值範圍介於 1 < k < 500

輸出說明 : 若輸入 a 10 a 3 a 8 b c, 則表示插入 10, 插入 3, 插入 8, 刪除最小值, 印出陣列中所有的內容 The min-heap is of size 1 and the current minimum is 10. The min-heap is of size 2 and the current minimum is 3. The min-heap is of size 3 and the current minimum is 3. The min-heap is of size 2 and the current minimum is 8. 8 10 注意執行 print 步驟以空白作為間隔, 每行要有句點, 最後必須有換行字元 範例 : Sample Input: a 8 a 19 a 4 a 90 a 3 a 2 b a 3 a 8 c d Sample Output: The min-heap is of size 1 and the current minimum is 8. The min-heap is of size 2 and the current minimum is 8. The min-heap is of size 3 and the current minimum is 4. The min-heap is of size 4 and the current minimum is 4. The min-heap is of size 5 and the current minimum is 3. The min-heap is of size 6 and the current minimum is 2. The min-heap is of size 5 and the current minimum is 3. The min-heap is of size 6 and the current minimum is 3. The min-heap is of size 7 and the current minimum is 3. 3 4 3 90 19 8 8

Problem 2. Domination in a path (Time Limit: 5 seconds) Problem Description A domination set of a graph is a node subset such that every node is either in the domination set or adjacent to a node in the set. Finding domination set of minimum total weight in general graph is an NP-hard problem. However, it can be efficiently computed by observing a recurrence relation if the input graph is a path. Input File Format The input is a path of n nodes, 1 n 90000. The weights of the nodes from left to right are given in one line. Each weight is a positive integer, 0 < w < 1000. Output Format Output the minimum weight of any domination set of this path. Example Sample Input: Sample Output: 10 20 30 40 50 50

Problem 3. 任務分配 (Time Limit: 5 seconds) 問題描述 : 任務分配, 計算最短任務所需時間 1. 一個方格代表一個任務, T1/4 : 代表 T1 任務需要 4 秒執行時間才能完成 2. 箭頭代表執行順序, 例如上圖所述 : T4 任務及 T5 任務需要等 T1 任務完成後才可進行 3. 一台處理器同一時間只能處理一個任務, 且必須做完該任務後, 才可以執行另一個任務 4. 所有的任務皆在初始化完成 例 : 假設有 3 台處理器, 處理上圖所述之任務 任務編號 所需時間 ( 秒 ) 執行順序 T1 4 無 T2 2 無 T3 2 無 T4 20 需等 T1,T2 完成才可進行 T5 20 需等 T1,T2,T3 完成才可進行 T6 11 需等 T2,T3 完成才可進行 T7 11 需等 T3 完成才可進行 請計算出如何安排, 才能在最少時間內完成所有任務呢?

輸入說明 : Process:N Task:task,time Prec:t1,t2 end N 台處理器任務, task 任務名稱, time 任務執行時間優先權, t1 必須在 t2 前執行, 也就是說 t2 必須等到 t1 結束才可以開始執行輸入結束符號程式開始執行 0 < N < 100,task 總數不超過 5000, 以小寫字母表示, 例如 : t1,t2, 各任務 執行時間介於 0 < time < 500 輸出說明 : 輸出所有任務所需最短執行時間, 最後必須有換行字元 範例 : Sample Input Process:3 Task:t1,4 Task:t2,2 Task:t3,2 Task:t4,20 Task:t5,20 Task:t6,11 Task:t7,11 Prec:t1,t4 Prec:t2,t4 Prec:t2,t5 Prec:t2,t6 Prec:t3,t5 Prec:t3,t6 Prec:t3,t7 end Sample Output 24

Problem 4. 網路多重最短路徑 (Time Limit: 5 seconds) 問題敘述 : 在圖 ( 網路 ) 中 最短路徑 的定義為網路中連接起始節點至目標節點的所有路徑中具有最小的 路徑權重值 網路中的路徑權重值是構成此路徑的所有 連線權重值 的總和 使用鄰接矩陣表示的網路其每一條連線的權重值都假設為 1 給予一代表無向連通圖的鄰接矩陣並指定起始節點與目標節點, 請計算出連接起始節點至目標節點的所有 ( 大於或等於 1) 最短路徑 輸入說明 : 輸入分為兩部份, 第一部份只有一行, 此行中有三個用逗號分隔開的介於 1 到 99 的數字, 第一個數字代表要計算的圖中節點數目 第二個數字與第三個 數字分別表示起始節點與目標節點 第二部份是鄰接矩陣, 總共列數剛好有節點個列, 每一列中有節點個由空隔分開的 0 或 1 第 i 列中的第 j 個 0 或 1 代表由節點 i 到節點 j 的連線是否存在 (0 表示不存在,1 表示存在 ) 沒有自我迴圈連線表示第 i 列中的第 i 個元素值為 0 連線沒有方向性, 因此鄰接矩陣為對稱矩陣 輸出說明 : 每一條最短路徑用一行表示, 列出由起始節點至目標節點的路徑中所經過的 節點編號 ( 包括起始節點與目標節點 ), 節點與節點間用逗號分隔開 若超過一組的最短路徑請依數字大小順序換行輸出, 最後必須有換行字元

範例 : Sample Input 9,1,5 0 1 0 1 0 0 0 0 0 1 0 1 0 1 0 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 1 0 0 0 1 0 1 0 1 0 1 0 0 0 1 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 0 1 0 1 0 1 0 0 0 0 0 1 0 1 0 Sample Output 1,2,5 1,4,5

Problem 5. Maximum Sub-sequence Product (Time Limit: 5 seconds) Problem Description Bob needs money, and since he knows you are here, he decided to gamble intelligently. The game is rather simple: each player gets a sequence of integers. The players must determine, by using their mega-pocket computers, which is the maximum product value which can be computed with non empty sub-sequences of consecutive numbers from the given sequence. The winner is the one which gets first the right result. Can you help Bob with a program to compute quickly the wanted product, particularly when the sequence is quite long? Input File Format The input file contains sequences of numbers. Each number will have at most 5 digits. There will be at most 100 numbers in each sequence. Each sequence starts on a new line and may continue on several subsequent lines. Each sequence ends with the number -999999 (which is not part of the sequence). No more than 10 sequences. Output Format The maximum sub-sequence product for each sequence must be written on the standard output, on a different line. A simple example is illustrated in the sample below. Example Sample Input: 1 2 3-999999 -5-2 2-30 -999999-8 -999999-1 0-2 -999999 Sample Output: 6 120-8 0