ACM ICPC 7th Sharif Internet Contest & Internal Selection Contest of Sharif

Similar documents
NOWCODER.COM 牛客网 - 中国最大 IT 笔试 / 面试题库 一. 编程题

Problem Y A limit 1 second. Zigzag

UCF Practice Local Contest Aug 23, 2014

Section Sets and Set Operations

Problem A: Collatz Conjecture

Problem A. Ascent Sequences

PLU February 2013 Programming Contest. Advanced Problems

Millionaire. Input. Output. Problem limit seconds

ACM ICPC Dhaka Regional Online Preliminary Contest th October 2018 You get 13 Pages 10 Problems

Problem A A New Alphabet

2016 ACM ICPC Southeast USA Regional Programming Contest. Division 1

Competitive Programming Network - 2nd Activity March 11th, Alphabet.c, Alphabet.cpp, Alphabet.java, Alphabet.py Standard Standard

Data Structure and Algorithm Homework #3 Due: 1:20pm, Thursday, May 16, 2017 TA === Homework submission instructions ===

CIS 110 Fall 2014 Introduction to Computer Programming 8 Oct 2014 Midterm Exam Name:

FINAL ROUND June 15 th, 2008

Problem A limit 1 second. Alphabet

Twentieth Annual University of Oregon Eugene Luks Programming Competition

Anti Brute Force Lock

Prepare a stem-and-leaf graph for the following data. In your final display, you should arrange the leaves for each stem in increasing order.

Pacific Northwest Region Programming Contest Division 2

Problem A. Character Encoding

COCI 2016/2017. Tasks. Round #3, November 26th, Task Time limit Memory limit Score. Imena 1 s 32 MB 50. Pohlepko 1 s 64 MB 80

MITOCW watch?v=0jljzrnhwoi

TASK CSS HISTOGRAMI MOSTOVI NIZOVI. time limit 5 seconds 1 second 1 second 1 second. memory limit 256 MB 256 MB 256 MB 256 MB. points

XV Open Cup named after E.V. Pankratiev Stage 6, Grand Prix of Japan, Sunday, February 1, 2015

Maratona de Programação UFPR

TASK NAJBOLJIH 5 OKRET ZADAĆA KOMPIĆI FUNKCIJA RASPORED. zadaca.pas zadaca.c zadaca.cpp

2015 Canadian Computing Competition: Junior Division. Sponsor:

XVIII Open Cup named after E.V. Pankratiev Stage 1: Grand Prix of Romania, Sunday, September 17, 2017

ENJOY! Problem 2 What does the following code do, in a brief English sentence? int mystery(int k) { int i = 0; if (k < 0) return -1;

Problem A. Find a Number

Aptitude Sample Questions

ACM International Collegiate Programming Contest 2013

Coding & Data Skills for Communicators Dr. Cindy Royal Texas State University - San Marcos School of Journalism and Mass Communication

Problem A. Alice the Fan

Student Outcomes. Lesson Notes. Classwork. Discussion (4 minutes)

TASK TABLICA ZBROJ EKIPA ZNANSTVENIK DIFERENCIJA MONO. ekipa.pas ekipa.c ekipa.cpp. zbroj.pas zbroj.c zbroj.cpp

Problems Overview. The 2015 Asia ACM-ICPC Hanoi Regional Contest. Note: The input and output for all the problems are standard input and output.

VISUAL GUIDE to. RX Scripting. for Roulette Xtreme - System Designer 2.0. L J Howell UX Software Ver. 1.0

11th Annual NB (English) High School Programming Competition

CSE548, AMS542: Analysis of Algorithms, Fall 2012 Date: October 16. In-Class Midterm. ( 11:35 AM 12:50 PM : 75 Minutes )

ACM ICPC2009 Latin American Regionals 1. Problem A Pangram. File code name: pangram

CS3 Midterm 1 Fall 2006

Problem Solving Strategies set of advanced problems

Out for Shopping-Understanding Linear Data Structures English

(Updated 29 Oct 2016)

BNPC-HS 2007 BABAK PENYISIHAN (PILIHAN GANDA)

Chapter 3 Analyzing Normal Quantitative Data

1. You have a complete bipartite graph where each part contains exactly n nodes, numbered from 0 to n - 1 inclusive.

Software Testing Prof. Rajib Mall Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur. Lecture 13 Path Testing

Stanford ProCo MAY 15, 2010 PROBLEM PACKET NOVICE DIVISION. Sponsored by:

Problem A. Interactive Smiley Face

Programming Problems 15th Annual Computer Science Programming Contest

A Bullseye. Problem. Output. For each dataset, print a line of the form: SCORE: N to M, PLAYER P WINS. Or: SCORE: N to M, TIE.

SUMMER REVIEW PACKET 2 FOR STUDENTS ENTERING ALGEBRA 1

HANDSHAKING AND CHASING KIDS

CMSC 201 Spring 2017 Project 1 Number Classifier

Program Development. Java Program Statements. Design. Requirements. Testing. Implementation

A rectangular field is to be fenced. The north side is 20 meters long and the area of the field is 680 squared meters. How many

Croatian Olympiad in Informatics. Task

Big Mathematical Ideas and Understandings

LOOPS. Repetition using the while statement

Problems for Op 2014

Problem A - Let s start the contest

CSC 101 Spring 2010 Lab #8 Report Gradesheet

2017 ACM ICPC ASIA, INDIA REGIONAL ONLINE CONTEST

The name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet.

You have three hours to complete this exam. There are 50 total points.

RBI PHASE 1 RECAP 2 ND JULY 18 QUANT NUMBER SYSTEM

Go to neptun.elte.hu and switch to English.

CPSC 217 Assignment 3

ACM Pacific NW Region Programming Contest 13 November 2004 Problem A: Mersenne Composite Numbers

Kharagpur Site Online Problems 2013

Intro. Scheme Basics. scm> 5 5. scm>

(Tests = 40%) + (Assignments = 40%) + (Participation = 20%) = (Quarter Final Grade)

Saturday Morning Math Group Austin Math Circle Austin Area Problem Solving Challenge

Fall 2018 #12 Geometry. A. View Angle. 2 seconds, 256 megabytes

2009 Consortium for Computing Sciences in Colleges Programming Contest Saturday, November 14 th Roanoke College Roanoke, VA

Database management system Prof. D. Janakiram Department of Computer Science and Engineering Indian Institute of Technology, Madras

Problem A Ceiling Function

Introduction to Access 97/2000

Problem Description Earned Max 1 PHP 25 2 JavaScript / DOM 25 3 Regular Expressions 25 TOTAL Total Points 100. Good luck! You can do it!

ASSIGNMENT 2. COMP-202A, Fall 2011, All Sections. Due: Monday, October 17th, 2011 (23:30)

The Ninth Annual Student Programming Contest. of the CCSC Southeastern Region. Saturday, November 9, :00 A.M. 12:00 P.M.

Honors Computer Science Python Mr. Clausen Programs 4A, 4B, 4C, 4D, 4E, 4F

2013 Four-by-Four Competition Thursday, January 31st, Round Four-by-Four Competition Thursday, January 31st, 2013.

1/15 2/19 3/23 4/28 5/12 6/23 Total/120 % Please do not write in the spaces above.

Congruence Arithmetic

CS261: HOMEWORK 2 Due 04/13/2012, at 2pm

Problem A Math for a Birthday Present

Learn Ninja-Like Spreadsheet Skills with LESSON 9. Math, Step by Step

Problem A. Tobby s Ancestors

Slide 1 CS 170 Java Programming 1 Testing Karel

Problem A Weekend Lottery

In how many different ways can the letters of the word 'DETAIL' be arranged in such a way that the vowels occupy only the odd positions?

Problem and Solution Overview: An elegant task management solution, that saves busy people time.

Integer Operations. Summer Packet 7 th into 8 th grade 1. Name = = = = = 6.

Fundamentals of Operations Research. Prof. G. Srinivasan. Department of Management Studies. Indian Institute of Technology, Madras. Lecture No.

Learning Objectives: General Description: DONE DONE Structure Chart

TASK CESTA PŠENICA PRIPREME MRAVI SABOR STANOVI. score

Transcription:

ACM ICPC 7th Sharif Internet Contest & Internal Selection Contest of Sharif 30 Mehr 1388 22 Oct. 2009 Contents Problem A: AMaTeuR HaCKeRS! 1 Problem B: Bahman s disapproval! 2 Problem C: Captivity of causality 3 Problem D: Dr. B and the pack of FANs 5 Problem E: Ehem, Ehem, Natural Born Losers! 7 Problem F: Factorials Again! 8 Problem G: Glamorous Polygons 9 Problem H: Horribly Fast Calculation 10 Problem I: Intergalactic Souvenirs 11

Note on all the problems: Your codes must read from standard input (stdin) and write to standard output (stdout). Problem A: AMaTeuR HaCKeRS! HaCKeR are different from crackers in their ethics. They are not always breaking the law. In contrast, they are interested in showing they are cool! One of their cool ness paradigms is to write words in HaCKeR S STYLe. In HaCKeR S STYLe, the first letter of a word is written in uppercase. But for the other letters (2 nd, 3 rd and so.) vowels (a, e, i, o, u) must be written in lowercase and CONSONANTS in uppercase. For example, PooR, BReaK, APPLe and KiLL are all in HaCKeR S STYLe. But none of the words BaNaNA, oil, MUSTaCHe or TRaINS are in our desired style! As a recruiter person of an Underground Hacking Group, you are asked to qualify new hackers. The procedure is that you ask any of them to write a full sentence and then you count the number of words they have written correctly in your style! First line of contains that is number of participants. In the th line below that, the sentence from the th participant is written (1 ). A sentence is defined as a sequence of at least one and at most 100 words, separated by one single space between any two adjacent words. A word is a string of at least one and at most 20 uppercase or lowercase English letters. For each participant, write his grade in the format shown in the sample output. Write the grades right in the order they come in the input. Sample 3 WeLCoMe to SHaRiF HaCK TeaM CAPSLOCK IS ON Polites Are Not Good Hackers Honey Sample 4 out of 5. 2 out of 3. 0 out of 6. 1

Problem B: Bahman s disapproval! Ali is a first year student in your university. In the first day of the new semester, he found that his studentidentification number (or shortly id), which was 88209689, is a prime number! He got happy and offered his friend Bahman, to have a tea break together. After a while, Bahman turned back to Ali and said Hey bro., that s not a rare thing!. Ali asked why?. Bahman replied While the range of new students id is 88200000, 88209999 (inclusive), with a possibility of 6%, one s id is prime! Now Ali (who has not passed even one programming course!), asks you to find out the chance of being lucky in the university (i.e. having a prime id). First line of contains that is number of the tests. Then, in each of the following lines, comes two 8 digit integers and. It s guaranteed that and any of these two numbers are either starting with 882 or starting with 881. For each test, print the percentage that a random number in range, is prime, in its own line. This percentage must be rounded to the nearest integer, followed by a percent sign (it is %). Sample 3 88200000 88209999 88209688 88209690 88199999 88200000 Sample 6% 33% 0% 2

Problem C: Captivity of causality Saeed is a brilliant student of University. University was a nice place for him until problems started to show up. Some of the problems are too simple and can be easily solved; but there are some amusing problems that even Saeed is not able to solve them by hand. These problems are in a wide range but they have one thing in common there is a method to describe them as logical expressions. Recently one of these problems (which you can see in the first sample input) has happened for him and after days of inspection and calculation, finally he made a list to describe his problem as logical expressions. The list was a set of accurate information in the following format: "expression1 because expression2." (quotes for clarity) We know that no expression is direct cause of itself and every expression has at most one cause. Now Saeed wants to find the source of his problems. So you are to write a program for him. consist of several test cases. First line of each test case contains (0 50) and (1 50) the number of information lines and the number of questions that Saeed has prepared for you, respectively. Each of next lines contains one sentence per line. It is guaranteed that there is exactly one " because " in each sentence and at least one nonspace character in every expression. Next lines contains a question in format "Why expression?" (Quotation marks are for clarity). terminates with two zeros for and. For each question output one of these sentences: "No reason.", "Too complicated.", "Because expression." (Quotes are for clarity). See sample input and sample output for more details. Print a blank line after each case. Sample 8 1 Saeed should spend his whole next term studying physics because Saeed failed to pass physics last term. Saeed's TA could not remember Saeed's face because Saeed's TA never looked at Saeed in TA classes. Saeed failed to pass physics last term because Saeed's physics mark was less than 10. 3

Saeed's physics mark was less than 10 because edu operator made a mistake while adding Saeed's physics marks. edu operator made a mistake while adding Saeed's physics marks because Saeed's TA released Saeed's mark in the last moment. Saeed's TA released Saeed's mark in the last moment because Saeed's TA was suspicious about Saeed. Saeed's TA was suspicious about Saeed because Saeed's TA could not remember Saeed's face. Saeed's TA never looked at Saeed in TA classes because there was another nice student in Saeed's TA classes. Why Saeed should spend his whole next term studying physics? 0 1 Why so serious? 4 5 a because b. b because a. c because b. d because e. Why a? Why b? Why c? Why d? Why e? 0 0 (Note: Long lines are wrapped. A complete line ends with a single dot.) Sample Because there was another nice student in Saeed's TA classes. No reason. Too complicated. Too complicated. Too complicated. Because e. No reason. 4

Problem D: Dr. B and the pack of FANs Dr. B is head of department of CE of university and he is interested in FANs. A FAN is defined as set of smart tricks that makes the life of students harder and more unpleasant. These FANs are infinitely various but after some researches, some students found some information about one kind of FANs which is called CSC (changing student s classes). Each term after the students select their classes, Dr. B starts to apply his FAN. This FAN allows him to change students classes in the following procedure: 1 He chooses a student id to apply his FAN. 2 He removes one of his/her classes. (optional) 3 He adds a new class instead of removed one. 4 Then he removes all the classes that conflict with the added class. 5 He adds a new class instead of every removed classes in the previous level. 6 While there is conflict a between classes repeat 4th and 5th level (step). This FAN has some restrictions: 1 After applying this FAN, number of classes should be the same as number of classes before applying it. 2 Each class can be removed at most once. 3 Each class can be added at most once. 4 Dr.B can not remove a class that he added before. 5 Dr.B can not add a class that he removed before. CSC_FANITY of a student is the maximum number of classes Dr. B can remove from his classes due to the rules and restrictions. In another words, CSC_FANITY is the number of classes that exist in the final schedule (after FANs of Dr. B) but were not selected in the initial schedule (prepare by the student). Little Aideen is new student of university and he is afraid of FANs. Your task is to write a program to compute CSC_FANITY of Aideen. Notice that Dr. B can apply his FAN only once for each student and you have to find out the FAN which brings maximum sadness to the student! consists of several test cases. first line of each test case comes (1 15) and (1, 5) being number of all classes (labeled from 1 to ) and number of classes that Aideen choose for his term. Next line consists of integers being label of Aideen classes. 5

Next lines contains 2 numbers and that shows start time and finish time of class number. These numbers show that class number starts in first second of th hour of week and ends in last second of th hour of week. (0 6 24). terminates with two zeros for and, this case should not be processed. For each case output an integer, CSC_FANITY of Aideen. Sample 2 1 1 1 3 4 6 Sample 1 0 3 2 1 3 1 2 2 3 3 4 0 0 6

Problem E: Ehem, Ehem, Natural Born Losers! Nima has always been a lucky boy in his life. But in ACM ICPC competitions, he is out of look! he has got two rank of first medalless team in World Final competitions! However, this problem is not all about him. ; ) Considering luck is a characteristical property of a person, It s believed that an ACM ICPC team, which has exactly three members, will get the first place in a competition if and only if all 3 members of that team be lucky. That means if we show lucky persons with L and others with U, a team of LLL will certainly get the 1 st rank; but not any team in the format of {ULL, LUL, LLU, LUU, ULU, UUL, UUU}. Unfortuantely, it is quite rough to ask directly from a contestant Are you lucky in ACM ICPC?. So you are hired to solve this puzzle! Given some sort of information about contests result (in the last competitions), you are asked to find out if an specific team has chance to get 1 st rank or not?, the number of test cases comes in the first line. After that, comes blocks, describing one test case each. Each block begins with a number that is the number of results we have about contestants. Following lines contain one result per line. A result begins with a single character + or -, which denotes the mentioned team has won (i.e. got the 1 st place) or lost in the history. After that symbol, comes the name of 3 different contestants of that time separated by a single space. The names are between one and twenty characters in length and from lowercase or uppercase letters of English alphabet. The names are case insensitive (i.e. Nima and nima are the same person). Finally in the last line of the block (which is line 2, regard to the block s size) comes the query. The query is the name of your willing team, to find if it possible that this team gets 1 st place or not? For each test, if the results are having contradiction to themselves, print Inconsistent data! in one line and advance to the next tests. Otherwise (the results are O.K.), if the specified team can get the 1 st place without any contradiction with the belief of luck, print Yes, they can win!, in a single line. And finally, if they have no chance to get the 1 st place, print in one line: No, they are natural-born-losers!. Sample 2 1 - Nima Saeed Aideen Nima Saeed Hessam 3 - Simul Segment Matching + Simul AliBaba Sorting + Nima Saeeed Aideen Matching Segment Sorting Sample Yes, they can win! No, they are natural-born-losers! 7

Problem F: Factorials Again! You may know how to compute number of zeros at the end of! in base10, but we want number of zeroes at the end of! in base. We define! 1 2. For example 5! 1 2 3 4 5 120 1111000 11110 1320. So number of zeroes at the end of 5! in base 3 is 1 and in base 2 is 3. consists of several test cases (at most 1,000). Each test case has two numbers, in a single line. 1 10 and 2 500,000,000. The last line of input contains two zeros which should not be processed. For each, in a test case, print the number of zeroes at the end of! in base in a single line.. Sample 5 2 5 3 5 10 123456789 1234 0 0 Sample 3 1 1 200416 8

Problem G: Glamorous Polygons Two polygons (with the same number of vertices) are given to you. The polygon has distinct vertices but may be degenerate in that the line segments could intersect. Because these polygons are generally created from remote images, there is some uncertainty as to their scale and rotation. Your job is to determine whether or not these two polygons are similar; that is, can they be made equal by repositioning, rotating and magnifying them? consists of multiple test cases. The first line of each test case is 3 100,000 that is the number of vertices in both polygons. Next N lines in that case describes the coordinate pairs of first polygon in counter clockwise order. Next N lines contain the coordinate pairs of second polygon in counter clockwise order. The coordinates of all vertices are less than 10 in absolute value. A line containing 0 defines the last test case; which should not be processed. For each case, output a line YES or NO as appropriate (i.e. YES where they are similar and NO when they are not). The two polygons are similar if, after some combination of translation, rotation, and scaling (but not reflection) both vertices corresponding to each feature are in the same position. Sample 3 0 0 1 0 0 1 2 0-1 3-1 0 3 0 0 1 0 0 1 0 0 0 1 0 5 0 Sample YES NO 9

Problem H: Horribly Fast Calculation You may know how to compute sum of all positive divisors for a positive integer, but we want sum of this number for 1 to as fast as possible. We define: = sum of all positive divisors of For example 12 1 2 3 4 6 12 28 And you should compute for all given inputs. consists of several test cases (at most 10,000). Each test case is a number in a single line that fits in 1 5,000,000. The last line of input is a single zero, which should not be processed. For each n in input you should write σ in a single line.. Sample 5 10 0 Sample 21 87 10

Problem I: Intergalactic Souvenirs E.T. (Extra Terrestrial an alien creature, who has come to the earth), has decided to go back to his planet. But before leaving the earth, he wants to pick two souvenirs one for his older brother S.T. (Super extra Terrestrial) and one for his younger sister N.T. (not necessarily extra Terrestrial)! E.T. s best friend, Elliot, has offered E.T. a pack of marbles. But since E.T. is too shy to accept all the marbles, he just wants to pick the heaviest marble for S.T. and the lightest one for N.T. You can consider no two marbles have the same weight, and they are indexed from 1 to. In order to find out which one is the heaviest and which one is the lightest, Elliot has brought a beam balance (scale) to E.T., and has already compared some pairs of marbles. The result of Elliot s scale actions are logged in the format i th marble is heavier than j th marble or i th marble is lighter than j th marble where. With the help of these results, E.T. wants to find the heaviest and lightest marbles with the minimum number of additional weightings. We know each weighting action is to compare exactly two marbles with each other no mass comparison is possible. Please help E.T., and tell him the minimum number of weightings he needs from now to find his proper souvenirs!, the number of test cases comes in the first line. After that, comes block, describing one test case each. Each block begins with two numbers N (, ) and then K (, ) where N is the number of marbles and K is the number of comparisons (weightings) Eliot has already done. Then in the following lines, comes one string (entered by user) per line in the format of i < j or i > j that means th marble is strictly lighter than th, or th marble is strictly heavier than th, respectively. It is guaranteed that 1,. Please attend that there exists a whitespace before and after < and > characters in these lines. For each test case, print Implausible in a separate line, if there is any contradiction in Elliot s results. Otherwise, print the minimum number of weightings E.T. has to do to find out heaviest and lightest marbles in its own line. Thus, your output must have exactly lines. Sample 4 2 1 1 < 2 3 1 3 > 2 5 3 1 > 2 3 < 2 3 > 1 4 0 Sample 0 2 Implausible 4 11