Wattanapong suttapak SE, ICT University of Phayao.

Slides:



Advertisements
Similar presentations
Part VI NP-Hardness. Lecture 23 Whats NP? Hard Problems.
Advertisements

Parents Weekend Presentation Arup Guha, EECS Lecturer and Programming Team Coach Special Thanks to Dr. Ali Orooji, the teams head coach who developed these.
ACM-ICPC Global Coverage
2011 ACM International Collegiate Programming Contest and ANZAC League 2011 Dr Alex Potanin Wellington Site Director South Pacific:
Spring 2003CSE P5481 Reorder Buffer Implementation (Pentium Pro) Hardware data structures retirement register file (RRF) (~ IBM 360/91 physical registers)
Parametric Throughput Analysis of Synchronous Data Flow Graphs
Final Project of Information Retrieval and Extraction by d 吳蕙如.
One Hull of A Rain Forest Green Computing Computer Science Neil Gordon January
Virginia Tech ACM ICPC Programming Team icpc.cs.vt.edu Virginia Tech Coach: Dr. Godmar Back.
Example – calculating interest until the amount doubles using a for loop: will calculate up to 1000 years, if necessary if condition decides when to terminate.
The Stagecoach Problem
Flowcharts Remember that a solution to a problem is called an algorithm. Algorithms are often a series of steps required to solve the problem. A flowchart.
Pseudo-polynomial time algorithm (The concept and the terminology are important) Partition Problem: Input: Finite set A=(a1, a2, …, an} and a size s(a)
How to Program in C++ CHAPTER 3: INPUT & OUTPUT INSTRUCTOR: MOHAMMAD MOJADDAM.
Copyright © Cengage Learning. All rights reserved. CHAPTER 11 ANALYSIS OF ALGORITHM EFFICIENCY ANALYSIS OF ALGORITHM EFFICIENCY.
Week 7 - Programming II Today – more features: – Loop control – Extending if/else – Nesting of loops Debugging tools Textbook chapter 7, pages
Learning to Drive A Marketing Machine Ted Mitchell.
The SiTProS Model (Siam Tsunami Propagation Simulator) Annual National Symposium on Computational Science and Engineering (ANSCSE11) Held at Phuket, Thailand,
Writing algorithms using the for-statement. Programming example 1: find all divisors of a number We have seen a program using a while-statement to solve.
Transportation 1. Learning Objectives Understand that gasoline combustion moves the vehicle as well as emit greenhouse gases. Understand that carbon emissions.
The History of Cars in America
7.3 Introduction to Relations and Functions
TH-OCR NK. content introduction go to next page background assumptions overall structure chart IPO for overall structure dataflow diagram of overall structure.
CPSC 171 Introduction to Computer Science 3 Levels of Understanding Algorithms More Algorithm Discovery and Design.
Example 9.1 Gasoline Prices in the United States Sampling Distributions.
2011 ACM International Collegiate Programming Contest and ANZAC League Dr Alex Potanin Wellington Site Director South Pacific:
CS0004: Introduction to Programming Variables – Strings.
Chapter 2.2 Functions. Relations and Functions Recall from Section 2.1 how we described one quantity in terms of another. The letter grade you receive.
Leontief Input-Output Analysis A way to analyze economics of interdependent sectors Case study: Oil and Transportation –Transportation requires gasoline.
Text Processing and More about Wrapper Classes
 A line segment in a scene is defined by the coordinate positions of the line end-points x y (2, 2) (7, 5)
ACM programming contest Introduction + Recursion.
Solving Problems Quickly UAkron Programming Team January 20, 2012.
Chapter 3: Formatted Input/Output Copyright © 2008 W. W. Norton & Company. All rights reserved. 1 Chapter 3 Formatted Input/Output.
Fundraising. Flowers Car Wash Candy Sale Patron Book.
ACM programming contest Introduction. ACM International Collegiate Programming Contest (a.k.a. ACM ICPC, ACM competition, ICPC) is the largest university-level.
1-5 Solving Equations with Rational Numbers Warm Up Warm Up Lesson Presentation Lesson Presentation Problem of the Day Problem of the Day Lesson Quizzes.
Copyright ©2005  Department of Computer & Information Science JavaScript Modularity.
Recursive Algorithms &
The MPG Illusion. Fuel Efficiency Ace drives a car that averages 10 mpg and is considering trading it in on a new car that averages 12 mpg. Buddy drives.
Welcoming Lecture Meeting/Discussion/Party By David/Denon.
Math, Data Types. Python Math Operations OperationOperator Addition + Subtraction – Multiplication * Division (floating point) / Division (integer) //
CARBON FOOTPRINT BY CHRISTIAN VAGTBORG.. WHAT IS IN A CARBON FOOTPRINT Carbon is a gas However, the total carbon footprint cannot be calculated because.
ALGORITHMS.
Continual Neighborhood Tracking for Moving Objects Yoshiharu Ishikawa Hiroyuki Kitagawa Tooru Kawashima University of Tsukuba, Japan
HKOI Programming HKOI Training Team (Intermediate) Alan, Tam Siu Lung Unu, Tse Chi Yung.
Discrete Controller Design
An Introduction to Programming with C++ Sixth Edition
Introduction to Programming Python Lab 3: Arithmetic 22 January PythonLab3 lecture slides.ppt Ping Brennan
INVITATION TO Computer Science 1 11 Chapter 2 The Algorithmic Foundations of Computer Science.
ESTIMATION Prepared by: Paolo Lorenzo Bautista. Estimation  We wish to estimate a characteristic of the population, by using information from the sample.
A Level Computing#BristolMet Session Objectives#U2S11 MUST identify built-in string manipulation functions SHOULD correctly use string manipulation functions.
Undergraduate Computing education in China XU, Yang Feb
Copyright © 2009 Pearson Education, Inc. 2.4 Index Numbers LEARNING GOAL Understand the concept of an index number; in particular, understand how the Consumer.
ANASOFT VIATUS. Challenges Supply chain optimization is necessary for achieving competitive price of final products Synchronization and utilization of.
Chapter 3: Formatted Input/Output 1 Chapter 3 Formatted Input/Output.
QNT 561 Week 2 Weekly Learning Assessments – Assignment
Problem Solving Flowcharts. Flowcharts Introduction  Flowcharts allow us to create a visual representation of a solution to a problem DRAW  With flowcharts,
1 Computing Functions with Turing Machines. 2 A function Domain Result Region has:
Loops Brent M. Dingle Texas A&M University Chapter 6 – Section 6.3 Multiway Branches (and some from Mastering Turbo Pascal 5.5, 3 rd Edition by Tom Swan)
Cars of the Future By: Savannah Baratta. Types of cars of the future and what they run on… Hybrid Hybrid cars use two types of distinct power sources.
Firms in a Competitive Market
Best Way to Increase the Efficiency of Your Car Engine
Way to Jumpstart your Car With a Bad Alternator
Binary Files.
Section 2.1 Input and Output
CSE322 Mealy and Moore Machine
Exercise Solution First questions What's output What's input
Chapter 6 Network Flow Models.
Formal Definitions for Turing Machines
Presentation transcript:

wattanapong suttapak SE, ICT University of Phayao

Sample Input ACM International Collegiate Programming Contest (abbreviated as ACM-ICPC or just ICPC) is an annual multi-tiered computer programming competition among the universities of the world. The contest is sponsored by IBM. Headquartered at Baylor University, with autonomous regions on six continents, the ICPC is directed by Baylor Professor William B. Poucher, Executive Director, and operates under the auspices of the Association for Computing Machinery (ACM). The 2012 ACM-ICPC Asia Hatyai Regional Programming Contest is held during November It is hosted by Prince of Songkla University, Hatyai campus. E-N-D Sample Output international

Solution 1. Scan แบบ next(); 2. trim string 3. check character ทีละตัวว่าเป็น isdigit หรือ “_” หรือไม่ 4. เปรียบเทียบ String ไหนยาวสุด แสดงค่า String นั้น

8 : 44 9 : 88 = : 70 = : : 68 = : : 60 = 7 15 : : : 56 = 3 18 : 6 19 : : : : 96 = : 86 = : 66 = : : : 104 = : 102 = : 98 = : 90 = : 74 = : : 84 = : 62 = 9 35 : : : 72 = : : 76 = : : 92 = : 78 = : : 100 = : 94 = : 82 = : 58 = 5 48 : : : : 80 = : : 1 54 : 2 55 : 4 56 : 8 57 : 16

0 : 1 1 : 3 2 : 9 3 : 27 4 : 81 = 28 5 : 243 = 31 6 : 729 = 40 7 : 14 8 : 42 9 : : 7 11 : : : : : 5 16 : : : : : : : : : : : : : : : : : : : : : : : : : : : : 8 44 : : : 4 47 : : : 2 50 : 6 51 : : 1 53 : 3 54 : 9 55 : 27 y : x

8 : 44 9 : 88 = : 70 = : : 68 = : : 60 = 7 15 : : : 56 = 3 18 : 6 19 : : : : 96 = : 86 = : 66 = : : : 104 = : 102 = : 98 = : 90 = : 74 = : : 84 = : 62 = 9 35 : : : 72 = : : 76 = : : 92 = : 78 = : : 100 = : 94 = : 82 = : 58 = 5 48 : : : : 80 = : : 1 54 : 2 55 : 4 56 : 8 57 : 16

0 : 1 1 : 3 2 : 9 3 : 27 4 : 81 = 28 5 : 243 = 31 6 : 729 = 40 7 : 14 8 : 42 9 : : 7 11 : : : : : 5 16 : : : : : : : : : : : : : : : : : : : : : : : : : : : : 8 44 : : : 4 47 : : : 2 50 : 6 51 : : 1 53 : 3 54 : 9 55 : 27

0 : 1 1 : 4 2 : 16 3 : 11 4 : 44 5 : 17 6 : 15 7 : 7 8 : 28 9 : 6 10 : : : : : : : : 9 18 : : : : : : : : : 1 27 : 4 28 : : : : : : 7 34 : : 6 36 : : : : : : : : 9 44 : : : : : : : : : 1 53 : 4 54 : : 11 คิดย้อนกลับ 5 : : : 41 ans. 41

Assume that the world is coming to its end. Mr. A and his family are among the very few people who stay alive. He is driving a car along the road in Bangkok center finding his way to get out of the city as soon as possible. However, the fuel is limited and most of the gas stations have just been wiped out by the earthquake. At this point, it becomes clear that the problem is how to select the best way to drive. Given that now Mr. A reaches the big junction with N ways to go. With the help of the GPS, which surprisingly can still function, the information about each way is provided in the form of the number of milestones and the amount of fuel to reach them. At this point Mr. A wants to go to any one of the N ways. Additionally, he wants to reach the last milestone in that chosen way. However, this information seems to be useless to Mr. A, now that he is in panic and temporarily loses an ability of calculations. Your task is to write the program to calculate a way that Mr. A should take with the minimum use of fuel. If there are two or more ways that consume the same amount of fuel, the program will always select the first one in the input file.

 Input:  The first line of the input is the number of test cases. This is followed by the input of each case one by one. For each case, the first line indicates an amount of gasoline in your car, K (K < 50). The second line shows the number of ways to go (N, N < 10). Then the information about each way out of all N ways is input. The information about each way contains M+1 lines where M (0 < M < 1000) is the number of milestones in that such way. The first line indicates M, followed by an amount of fuel required to reach each milestone. Note that the amount of fuels required to reach any milestone is an integer and calculated from the current car position. Each test case is ended with character E.  Output:  The output of each test case is shown respectively. For each case, the first line shows the index number of the way Mr. A should take and the second line shows a total amount of fuel for driving in such way. The third line states the result if Mr. A will finally reaches the destination. The “Y” means yes and “N” means no.

inputoutput