SlideShare a Scribd company logo
1 of 50
Download to read offline
cse seminar series
Experiences and Problems from
the ACM-ICPC 2016 Regionals
Akash Pallath Chinmay Sonar P.R. Vaidyanathan
(from pyoneers import *)
April 17, 2017
Indian Institute of Technology Gandhinagar
experiences
acm-icpc format
∙ Team contest - 3 members (+1 optional reserve)
∙ Online Qualifiers -> Onsite Regionals -> India Finals -> World
Finals
∙ Onsite Regionals in India - Amritapuri, Chennai, Kharagpur,
Kolkata
∙ India Finals - Kolkata, Gwalior (top N teams selected from each
site)
∙ Qualifiers - 7 questions, 3 hours
∙ Onsite rounds - 10-13 questions, 5 hours
∙ Different difficulty levels - E.g. - at Chennai, top team solved 6
out of 10 problems (3 problems remained unsolved by any
team), at Amritapuri, same team solved 10 out of 11 problems
(only 1 problem remained unsolved by any team)
2
our experience
∙ Chennai - Ranked 56 (out of 128 teams). Solved 4. Top team
solved 6.
∙ Amritapuri - Ranked 40 at Coimbatore subsite (out of 124
teams). Solved 3 :( Top team solved 10.
∙ Learning experience
∙ Interaction with competitive programming community
∙ Language issues - Python, although slower, given same time
limit constraints on DOMJudge (Amritapuri). CodeChef, however,
gives Python 5 × time limit, and Java 2 × time limit (all other
sites).
∙ Used Python for cakewalk problems, C++ for the rest.
3
some photos
4
Problems from Chennai Regionals
5
voting fraud
chn16g - voting fraud
Problem Statistics
∙ Total correct submissions - 117
∙ Accuracy - 89.31%
∙ Number of submissions we made - 1
∙ Verdict - AC
7
brief problem statement
There are N students who took part in the voting. Each student has a
student ID using that they will vote. Help the officials to find out if
any one has voted more than once, by giving them the total number
of fraud votes. Each student is supposed to cast at most one vote
only. So, if a students has cast more than one vote, all votes except
one vote will be fraud votes.
8
constraints and examples
Constraints:
∙ 1 ≤ T ≤ 100
∙ 1 ≤ N ≤ 100
∙ 1 ≤ Ai ≤ 100
Examples:
1. Given the total number of votes casted to be 4 and the actual
voter ID’s are 1, 2, 3, 2
Answer: 1
2. Given the total number of votes casted to be 4 and the actual
voter ID’s are 1, 2, 2, 2
Answer: 2
9
Solution?
10
time complexity
Running time: Time required to process all the input voter ID’s and
each voter ID can be processed in constant time. Hence, the total
running time is,
n ∗ constant ≈ O(n)
11
world finals accommodation
chn16f - acm-icpc world finals accommodation
Problem Statistics
∙ Total correct submissions - 116
∙ Accuracy - 61.7%
∙ Number of submissions we made - 1
∙ Verdict - AC
13
brief problem statement
Given a floor of n ∗ m rooms arranged in a rectangular fashion. There
are teams from total of C countries, with each country having ci
teams. We need to accommodate these teams such that, all the
teams from a country should be able to communicate with each
other.
The condition for communication between teams is,
1. when 2 teams of same country share a common wall
2. when 2 teams of same country have common neighbor (i.e.
neighbor is a team sharing a wall) of the same country
14
constraints and examples
Constraints:
∙ 1 ≤ T, n, m ≤ 50
∙ 1 ≤ C, ci ≤ n ∗ m
∙
∑
ci = n ∗ m
Examples:
1. Given a 2 ∗ 2 rectangular hall with 4 rooms. Accommodate the
teams from 2 countries satisfying the given condition such that,
there are 2 teams from each country.
2. Given a 2 ∗ 2 rectangular hall with 4 rooms. Accommodate 4
teams from a single country
15
Solution?
16
time complexity:
Running time: Time required to print the output. We need to output
n ∗ m numbers. Hence, total running time is,
O(nm)
17
birthday pizza party
chn16c - birthday pizza party
Problem Statistics
∙ Total correct submissions - 85
∙ Accuracy - 24.71%
∙ Number of submissions we made - 3
∙ Verdict - 2 WA [Integer Overflow], 1 AC
19
brief problem statement
Steffi wants to treat N friends at her birthday party. Every pizza can
be divided into A equal pieces. Find the minimum number of Pizzas
she should buy given that,
∙ Each friend should get equal number of pieces
∙ Steffi should get exactly one piece
∙ Any piece of pizza should not be wasted
20
constraints and examples
Constraints:
∙ 1 ≤ T ≤ 100, 000
∙ 1 ≤ A ≤ 1012
∙ 1 ≤ N ≤ 1012
Examples:
1. The number of friends (N) is 3 and a pizza can be divided into
(A) 2 parts.
Answer: 2
2. The number of friends (N) is 4 and pizza cannot be further
subdivided into smaller parts (A = 1) (i.e. 1 pizza = 1 piece).
Answer: 5
21
Solution?
22
solution
Assume,
X → minimum number of pizza(s) that should be bought
I → number of pieces given to each friend
To satisfy the given constraints we need to solve,
AX − NI = 1 (1)
Claims:
1. On the RHS of (1) we can only obtain integer multiples of
(GCD(A, N))
2. GCD of any 2 numbers can be expressed as linear combination
of those 2 numbers with integral coefficients [Bézout’s Identity]
23
mancunian candidate master forever
chn16b - mancunian candidate master forever
Problem Statistics
∙ Total correct submissions - 38
∙ Accuracy - 33.05%
∙ Number of submissions we made - 1
∙ Verdict - AC
25
problem statement
∙ You are given N drinks
∙ Each drink is characterized by the salt and sugar in it
∙ Each drink also has a cost associated with it
∙ Your task is to find a subset of drinks of minimum cost to buy
∙ Such that all the drinks can be ”prepared” using the purchased
drinks
26
problem statement
Definition
Preparing a drink, means mixing two or more drinks in some
proportion, yielding a new drink. The sugar and salt in this drink is
the weighted mean of the sugar and salt contents of the constituent
drinks.
Note
It is not necessary to prepare all the N drinks simultaneously.
It is sufficient to be able to prepare all the N drinks independently.
27
example
Name Sugar Salt Cost
A 4 2 1
B 3 3 5
C 2 4 10
Answer: Drink A and Drink B costing 11. Mixing them in 1:1 proportion
gives Drink C
28
Solution
29
solution
Intuition
∙ Represent a drink with x mg sugar and y mg salt as (x, y)
∙ Visualize drink as a point on Cartesian plane
∙ Understand what mixing means in this setting
∙ Ignore cost aspect, for now just try to find a subset of drinks
which can be used to prepare the remaining
30
solution
1 2 3 4 5
1
2
3
4
5
C(2,4)
B(3,3)
A(4,2)
Figure: Example 1
31
solution
1 2 3 4 5
1
2
3
4
5
C(2,4)
B(5,5)
A(4,2)
D(4,4)
Figure: Example 2
32
alice and bob play contact
chn16i - alice and bob play contact
Problem Statistics
∙ Total correct submissions - 69
∙ Accuracy - 25.94%
∙ Number of submissions we made - 0 (fell short of time).
34
brief problem statement
∙ Alice’s ’Vocabulary’ - set of strings SAlice = {A1, A2, . . . , An}
∙ Bob’s ’Vocabulary’ - set of strings SBob = {B1, B2, . . . , Bm}
∙ A game is played for each word Ai in SAlice
∙ In the jth
iteration of the ith
game, Bob uses a word from SBob
that has a prefix of length j common with Ai.
∙ In a particular game, Bob cannot re-use a word he has already
used in that game.
∙ Game ends when Bob has made |Ai| moves, or when Bob has no
word left to make a move.
35
brief problem statement
∙ Problem: Find the sum of maximum number of moves Bob can
make for each of the n games.
Constraints
∙ 1 ≤ n, m ≤ 105
∙ 1 ≤ |Ai|, |Bi| ≤ 105
∙ 1 ≤
∑n
i−1 |Ai| ≤ 106
∙ 1 ≤
∑m
i−1 |Bi| ≤ 106
∙ All strings consist of upper-case English alphabets
∙ All strings in SAlice are distinct, all strings in SBob are distinct
36
strategies
Aim
Maximize the length of each game.
Strategy 1
For jth
move in a game, pick up any word from SBob which has prefix
of length j in common with Ai.
Will this work?
Strategy 2
For jth
move in a game, select an unused word from SBob with
minimum prefix length ≥ j, common with Ai.
This is the optimal strategy
37
naive solution
∙ For each game i, maintain a list of words from SBob, with the
option to mark words as ’used’.
∙ Calculate and store the lengths of prefixes of each word with Ai.
∙ At iteration j, pick a usable word that has minimum length of
common prefix with Ai, such that the prefix length is ≥ j. Mark
this word as used.
∙ If no such word is found, or if j > |Ai|, then the game has
terminated
38
time complexity
∙ For each game i, maintain a list of words from SBob, with the
option to mark words as ’used’. O(n) iterations
∙ Calculate and store the lengths of prefixes of each word from
SBob with Ai. O(|Ai| +
∑m
j=1 |Bj|) time
∙ At iteration j, pick a usable word that has minimum length of
common prefix with Ai, such that the prefix length is ≥ j. Mark
this word as used.
∙ If no such word is found, or if j > |Ai|, then the game has
terminated.
Running time is O(
∑n
i=1 |Ai| + n ×
∑m
j=1 |Bj|)
= O(106
+ 105
× 106
) = O(1011
) operations
Verdict
Time Limit Exceeded
39
Can we do better?
40
moving to an efficient algorithm
Question
Can we bring the running time down to O(
∑n
i=1 |Ai| +
∑m
j=1 |Bj|)?
How?
A hint to the approach
For each Ai in SAlice, determine length of game by scanning a single
word in Bob’s vocabulary.
Another hint
The alphabet size is fixed (only uppercase letters). Why would the
problem author set this constraint?
Everything points to a Trie-based approach
41
moving to an efficient algorithm
∙ Hoard all Bob’s strings into a trie. O(
∑m
i=1 |Bi|) = O(106
)
∙ At each node, maintain total number of leaves reachable from
that node.
∙ For each string Ai, search for Ai in trie - following certain
constraints:
∙ If there are nx strings at node x, one of them has to be used at
that node
∙ Greedy strategy - use string that overlaps as little as possible with
search path
42
an example to demonstrate the approach
Bob’s Vocabulary
∙ ant
∙ bat
∙ bestow
∙ bested
∙ besxyz
∙ bust
∙ cat
Alice’s current word : bestow
https://www.cs.usfca.edu/ galles/visualization/Trie.html
43
final algorithm
Algorithm 1 Determining Length of a Game
1: glen ← 0, avl ← |Ai|, j ← 0
2: t ← root of trie
3: while j < |Ai| do
4: if avl = 0 then
5: break
6: if jth
character of Ai not found in trie then
7: break
8: t ← node of trie storing jth
character of Ai
9: avl ← min(avl-1 , paths from t -1)
10: glen ← glen + 1, j ← j + 1
11: glen is the maximum game length
44
final algorithm
Running Time
O(
∑n
i=1 |Ai| +
∑m
j=1 |Bj|) i.e. approx 2 × 106
operations
Verdict
Accepted
45
attribution
This presentation has been made using the LATEX theme mtheme
Get the source of this theme and the demo presentation from
github.com/matze/mtheme
The theme itself is licensed under a Creative Commons
Attribution-ShareAlike 4.0 International License.
cba
46
Thanks!
47
Questions?
48
useful material
Links to Problems (ACM-ICPC Asia Chennai 2016 Regionals)
Problem Link
Voting Fraud CHN16G
ACM ICPC World Finals Accomodation CHN16F
Birthday Pizza Party CHN16C
Mancunian Candidate Master Forever CHN16B
Alice and Bob Play Contact CHN16I
Applet Demonstrating CHN16B (developed by P.R. Vaidyanathan)
49

More Related Content

What's hot

Elliptical curve cryptography
Elliptical curve cryptographyElliptical curve cryptography
Elliptical curve cryptographyBarani Tharan
 
Elliptic Curve Cryptography and Zero Knowledge Proof
Elliptic Curve Cryptography and Zero Knowledge ProofElliptic Curve Cryptography and Zero Knowledge Proof
Elliptic Curve Cryptography and Zero Knowledge ProofArunanand Ta
 
Elliptic Curve Cryptography
Elliptic Curve CryptographyElliptic Curve Cryptography
Elliptic Curve CryptographyJorgeVillamarin5
 
Lego like spheres and tori, enumeration and drawings
Lego like spheres and tori, enumeration and drawingsLego like spheres and tori, enumeration and drawings
Lego like spheres and tori, enumeration and drawingsMathieu Dutour Sikiric
 
Probability and Stochastic Processes A Friendly Introduction for Electrical a...
Probability and Stochastic Processes A Friendly Introduction for Electrical a...Probability and Stochastic Processes A Friendly Introduction for Electrical a...
Probability and Stochastic Processes A Friendly Introduction for Electrical a...KionaHood
 
Mit15 082 jf10_lec01
Mit15 082 jf10_lec01Mit15 082 jf10_lec01
Mit15 082 jf10_lec01Saad Liaqat
 
Probability and stochastic processes 3rd edition Quiz Solutions
Probability and stochastic processes 3rd edition Quiz SolutionsProbability and stochastic processes 3rd edition Quiz Solutions
Probability and stochastic processes 3rd edition Quiz SolutionsChristopher Whitworth
 
5.3 dynamic programming
5.3 dynamic programming5.3 dynamic programming
5.3 dynamic programmingKrish_ver2
 
Gate Computer Science Solved Paper 2007
Gate Computer Science Solved Paper 2007 Gate Computer Science Solved Paper 2007
Gate Computer Science Solved Paper 2007 Rohit Garg
 
Elliptic Curve Cryptography
Elliptic Curve CryptographyElliptic Curve Cryptography
Elliptic Curve CryptographyKelly Bresnahan
 
Ee gate-15-paper-02 new2
Ee gate-15-paper-02 new2Ee gate-15-paper-02 new2
Ee gate-15-paper-02 new2Sreenadh Reddy
 
Aaex7 group2(中英夾雜)
Aaex7 group2(中英夾雜)Aaex7 group2(中英夾雜)
Aaex7 group2(中英夾雜)Shiang-Yun Yang
 
Approximation algorithms
Approximation algorithmsApproximation algorithms
Approximation algorithmsGanesh Solanke
 
Cs6402 design and analysis of algorithms may june 2016 answer key
Cs6402 design and analysis of algorithms may june 2016 answer keyCs6402 design and analysis of algorithms may june 2016 answer key
Cs6402 design and analysis of algorithms may june 2016 answer keyappasami
 

What's hot (20)

Backtracking
BacktrackingBacktracking
Backtracking
 
Elliptical curve cryptography
Elliptical curve cryptographyElliptical curve cryptography
Elliptical curve cryptography
 
Elliptic Curve Cryptography and Zero Knowledge Proof
Elliptic Curve Cryptography and Zero Knowledge ProofElliptic Curve Cryptography and Zero Knowledge Proof
Elliptic Curve Cryptography and Zero Knowledge Proof
 
Lecture26
Lecture26Lecture26
Lecture26
 
Elliptic Curve Cryptography
Elliptic Curve CryptographyElliptic Curve Cryptography
Elliptic Curve Cryptography
 
Ecc2
Ecc2Ecc2
Ecc2
 
Lego like spheres and tori, enumeration and drawings
Lego like spheres and tori, enumeration and drawingsLego like spheres and tori, enumeration and drawings
Lego like spheres and tori, enumeration and drawings
 
Digi qestions
Digi qestionsDigi qestions
Digi qestions
 
Probability and Stochastic Processes A Friendly Introduction for Electrical a...
Probability and Stochastic Processes A Friendly Introduction for Electrical a...Probability and Stochastic Processes A Friendly Introduction for Electrical a...
Probability and Stochastic Processes A Friendly Introduction for Electrical a...
 
Mit15 082 jf10_lec01
Mit15 082 jf10_lec01Mit15 082 jf10_lec01
Mit15 082 jf10_lec01
 
Probability and stochastic processes 3rd edition Quiz Solutions
Probability and stochastic processes 3rd edition Quiz SolutionsProbability and stochastic processes 3rd edition Quiz Solutions
Probability and stochastic processes 3rd edition Quiz Solutions
 
5.3 dynamic programming
5.3 dynamic programming5.3 dynamic programming
5.3 dynamic programming
 
Gate Computer Science Solved Paper 2007
Gate Computer Science Solved Paper 2007 Gate Computer Science Solved Paper 2007
Gate Computer Science Solved Paper 2007
 
Elliptic Curve Cryptography
Elliptic Curve CryptographyElliptic Curve Cryptography
Elliptic Curve Cryptography
 
Ee gate-15-paper-02 new2
Ee gate-15-paper-02 new2Ee gate-15-paper-02 new2
Ee gate-15-paper-02 new2
 
Daa chapter 3
Daa chapter 3Daa chapter 3
Daa chapter 3
 
1524 elliptic curve cryptography
1524 elliptic curve cryptography1524 elliptic curve cryptography
1524 elliptic curve cryptography
 
Aaex7 group2(中英夾雜)
Aaex7 group2(中英夾雜)Aaex7 group2(中英夾雜)
Aaex7 group2(中英夾雜)
 
Approximation algorithms
Approximation algorithmsApproximation algorithms
Approximation algorithms
 
Cs6402 design and analysis of algorithms may june 2016 answer key
Cs6402 design and analysis of algorithms may june 2016 answer keyCs6402 design and analysis of algorithms may june 2016 answer key
Cs6402 design and analysis of algorithms may june 2016 answer key
 

Similar to Pyoneers - IITGN CSE Seminar Presentation

dynamic programming Rod cutting class
dynamic programming Rod cutting classdynamic programming Rod cutting class
dynamic programming Rod cutting classgiridaroori
 
counting techniques
counting techniquescounting techniques
counting techniquesUnsa Shakir
 
Tcs 2011with solutions
Tcs 2011with solutionsTcs 2011with solutions
Tcs 2011with solutionsAshu0711
 
500 most asked apti ques in tcs, wipro, infos(105pgs)
500 most asked apti ques in tcs, wipro, infos(105pgs)500 most asked apti ques in tcs, wipro, infos(105pgs)
500 most asked apti ques in tcs, wipro, infos(105pgs)PRIYANKKATIYAR2
 
Machine Learning Chapter 11 2
Machine Learning Chapter 11 2Machine Learning Chapter 11 2
Machine Learning Chapter 11 2butest
 
Permutations and Combinations IIT JEE+Olympiad Lecture 1
Permutations and Combinations IIT JEE+Olympiad Lecture 1 Permutations and Combinations IIT JEE+Olympiad Lecture 1
Permutations and Combinations IIT JEE+Olympiad Lecture 1 Parth Nandedkar
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programmingGopi Saiteja
 
programminghomeworkhelp.com_Advanced Algorithms Homework Help.pptx
programminghomeworkhelp.com_Advanced Algorithms Homework Help.pptxprogramminghomeworkhelp.com_Advanced Algorithms Homework Help.pptx
programminghomeworkhelp.com_Advanced Algorithms Homework Help.pptxProgramming Homework Help
 
Day 8 one step equations
Day 8 one step equationsDay 8 one step equations
Day 8 one step equationsErik Tjersland
 
Day 8 one step equations
Day 8 one step equationsDay 8 one step equations
Day 8 one step equationsErik Tjersland
 
Lecture 5 Binomial Distribution.pptx
Lecture 5 Binomial Distribution.pptxLecture 5 Binomial Distribution.pptx
Lecture 5 Binomial Distribution.pptxABCraftsman
 
GMAT Quant Strategy- What to expect in Quantitative Reasoning Section on the ...
GMAT Quant Strategy- What to expect in Quantitative Reasoning Section on the ...GMAT Quant Strategy- What to expect in Quantitative Reasoning Section on the ...
GMAT Quant Strategy- What to expect in Quantitative Reasoning Section on the ...CrackVerbal
 
Dynamic Programming
Dynamic ProgrammingDynamic Programming
Dynamic ProgrammingSahil Kumar
 
1) Let P(A) = 0.35, P(B) = 0.30, and P(A ∩ B) = 0.17.a.Are A.docx
1) Let P(A) = 0.35, P(B) = 0.30, and P(A ∩ B) = 0.17.a.Are A.docx1) Let P(A) = 0.35, P(B) = 0.30, and P(A ∩ B) = 0.17.a.Are A.docx
1) Let P(A) = 0.35, P(B) = 0.30, and P(A ∩ B) = 0.17.a.Are A.docxdorishigh
 

Similar to Pyoneers - IITGN CSE Seminar Presentation (20)

dynamic programming Rod cutting class
dynamic programming Rod cutting classdynamic programming Rod cutting class
dynamic programming Rod cutting class
 
counting techniques
counting techniquescounting techniques
counting techniques
 
Tcs 2011with solutions
Tcs 2011with solutionsTcs 2011with solutions
Tcs 2011with solutions
 
500 questions.pdf
500 questions.pdf500 questions.pdf
500 questions.pdf
 
500 most asked apti ques in tcs, wipro, infos(105pgs)
500 most asked apti ques in tcs, wipro, infos(105pgs)500 most asked apti ques in tcs, wipro, infos(105pgs)
500 most asked apti ques in tcs, wipro, infos(105pgs)
 
Algorithms Exam Help
Algorithms Exam HelpAlgorithms Exam Help
Algorithms Exam Help
 
Machine Learning Chapter 11 2
Machine Learning Chapter 11 2Machine Learning Chapter 11 2
Machine Learning Chapter 11 2
 
Mit6 006 f11_quiz1
Mit6 006 f11_quiz1Mit6 006 f11_quiz1
Mit6 006 f11_quiz1
 
Chapter2009
Chapter2009Chapter2009
Chapter2009
 
Permutations and Combinations IIT JEE+Olympiad Lecture 1
Permutations and Combinations IIT JEE+Olympiad Lecture 1 Permutations and Combinations IIT JEE+Olympiad Lecture 1
Permutations and Combinations IIT JEE+Olympiad Lecture 1
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 
MFCS UNIT-III.pptx
MFCS UNIT-III.pptxMFCS UNIT-III.pptx
MFCS UNIT-III.pptx
 
programminghomeworkhelp.com_Advanced Algorithms Homework Help.pptx
programminghomeworkhelp.com_Advanced Algorithms Homework Help.pptxprogramminghomeworkhelp.com_Advanced Algorithms Homework Help.pptx
programminghomeworkhelp.com_Advanced Algorithms Homework Help.pptx
 
Day 8 one step equations
Day 8 one step equationsDay 8 one step equations
Day 8 one step equations
 
Day 8 one step equations
Day 8 one step equationsDay 8 one step equations
Day 8 one step equations
 
Lecture 5 Binomial Distribution.pptx
Lecture 5 Binomial Distribution.pptxLecture 5 Binomial Distribution.pptx
Lecture 5 Binomial Distribution.pptx
 
GMAT Quant Strategy- What to expect in Quantitative Reasoning Section on the ...
GMAT Quant Strategy- What to expect in Quantitative Reasoning Section on the ...GMAT Quant Strategy- What to expect in Quantitative Reasoning Section on the ...
GMAT Quant Strategy- What to expect in Quantitative Reasoning Section on the ...
 
Algorithms Exam Help
Algorithms Exam HelpAlgorithms Exam Help
Algorithms Exam Help
 
Dynamic Programming
Dynamic ProgrammingDynamic Programming
Dynamic Programming
 
1) Let P(A) = 0.35, P(B) = 0.30, and P(A ∩ B) = 0.17.a.Are A.docx
1) Let P(A) = 0.35, P(B) = 0.30, and P(A ∩ B) = 0.17.a.Are A.docx1) Let P(A) = 0.35, P(B) = 0.30, and P(A ∩ B) = 0.17.a.Are A.docx
1) Let P(A) = 0.35, P(B) = 0.30, and P(A ∩ B) = 0.17.a.Are A.docx
 

Recently uploaded

Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...RKavithamani
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 

Recently uploaded (20)

INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 

Pyoneers - IITGN CSE Seminar Presentation

  • 1. cse seminar series Experiences and Problems from the ACM-ICPC 2016 Regionals Akash Pallath Chinmay Sonar P.R. Vaidyanathan (from pyoneers import *) April 17, 2017 Indian Institute of Technology Gandhinagar
  • 3. acm-icpc format ∙ Team contest - 3 members (+1 optional reserve) ∙ Online Qualifiers -> Onsite Regionals -> India Finals -> World Finals ∙ Onsite Regionals in India - Amritapuri, Chennai, Kharagpur, Kolkata ∙ India Finals - Kolkata, Gwalior (top N teams selected from each site) ∙ Qualifiers - 7 questions, 3 hours ∙ Onsite rounds - 10-13 questions, 5 hours ∙ Different difficulty levels - E.g. - at Chennai, top team solved 6 out of 10 problems (3 problems remained unsolved by any team), at Amritapuri, same team solved 10 out of 11 problems (only 1 problem remained unsolved by any team) 2
  • 4. our experience ∙ Chennai - Ranked 56 (out of 128 teams). Solved 4. Top team solved 6. ∙ Amritapuri - Ranked 40 at Coimbatore subsite (out of 124 teams). Solved 3 :( Top team solved 10. ∙ Learning experience ∙ Interaction with competitive programming community ∙ Language issues - Python, although slower, given same time limit constraints on DOMJudge (Amritapuri). CodeChef, however, gives Python 5 × time limit, and Java 2 × time limit (all other sites). ∙ Used Python for cakewalk problems, C++ for the rest. 3
  • 6. Problems from Chennai Regionals 5
  • 8. chn16g - voting fraud Problem Statistics ∙ Total correct submissions - 117 ∙ Accuracy - 89.31% ∙ Number of submissions we made - 1 ∙ Verdict - AC 7
  • 9. brief problem statement There are N students who took part in the voting. Each student has a student ID using that they will vote. Help the officials to find out if any one has voted more than once, by giving them the total number of fraud votes. Each student is supposed to cast at most one vote only. So, if a students has cast more than one vote, all votes except one vote will be fraud votes. 8
  • 10. constraints and examples Constraints: ∙ 1 ≤ T ≤ 100 ∙ 1 ≤ N ≤ 100 ∙ 1 ≤ Ai ≤ 100 Examples: 1. Given the total number of votes casted to be 4 and the actual voter ID’s are 1, 2, 3, 2 Answer: 1 2. Given the total number of votes casted to be 4 and the actual voter ID’s are 1, 2, 2, 2 Answer: 2 9
  • 12. time complexity Running time: Time required to process all the input voter ID’s and each voter ID can be processed in constant time. Hence, the total running time is, n ∗ constant ≈ O(n) 11
  • 14. chn16f - acm-icpc world finals accommodation Problem Statistics ∙ Total correct submissions - 116 ∙ Accuracy - 61.7% ∙ Number of submissions we made - 1 ∙ Verdict - AC 13
  • 15. brief problem statement Given a floor of n ∗ m rooms arranged in a rectangular fashion. There are teams from total of C countries, with each country having ci teams. We need to accommodate these teams such that, all the teams from a country should be able to communicate with each other. The condition for communication between teams is, 1. when 2 teams of same country share a common wall 2. when 2 teams of same country have common neighbor (i.e. neighbor is a team sharing a wall) of the same country 14
  • 16. constraints and examples Constraints: ∙ 1 ≤ T, n, m ≤ 50 ∙ 1 ≤ C, ci ≤ n ∗ m ∙ ∑ ci = n ∗ m Examples: 1. Given a 2 ∗ 2 rectangular hall with 4 rooms. Accommodate the teams from 2 countries satisfying the given condition such that, there are 2 teams from each country. 2. Given a 2 ∗ 2 rectangular hall with 4 rooms. Accommodate 4 teams from a single country 15
  • 18. time complexity: Running time: Time required to print the output. We need to output n ∗ m numbers. Hence, total running time is, O(nm) 17
  • 20. chn16c - birthday pizza party Problem Statistics ∙ Total correct submissions - 85 ∙ Accuracy - 24.71% ∙ Number of submissions we made - 3 ∙ Verdict - 2 WA [Integer Overflow], 1 AC 19
  • 21. brief problem statement Steffi wants to treat N friends at her birthday party. Every pizza can be divided into A equal pieces. Find the minimum number of Pizzas she should buy given that, ∙ Each friend should get equal number of pieces ∙ Steffi should get exactly one piece ∙ Any piece of pizza should not be wasted 20
  • 22. constraints and examples Constraints: ∙ 1 ≤ T ≤ 100, 000 ∙ 1 ≤ A ≤ 1012 ∙ 1 ≤ N ≤ 1012 Examples: 1. The number of friends (N) is 3 and a pizza can be divided into (A) 2 parts. Answer: 2 2. The number of friends (N) is 4 and pizza cannot be further subdivided into smaller parts (A = 1) (i.e. 1 pizza = 1 piece). Answer: 5 21
  • 24. solution Assume, X → minimum number of pizza(s) that should be bought I → number of pieces given to each friend To satisfy the given constraints we need to solve, AX − NI = 1 (1) Claims: 1. On the RHS of (1) we can only obtain integer multiples of (GCD(A, N)) 2. GCD of any 2 numbers can be expressed as linear combination of those 2 numbers with integral coefficients [Bézout’s Identity] 23
  • 26. chn16b - mancunian candidate master forever Problem Statistics ∙ Total correct submissions - 38 ∙ Accuracy - 33.05% ∙ Number of submissions we made - 1 ∙ Verdict - AC 25
  • 27. problem statement ∙ You are given N drinks ∙ Each drink is characterized by the salt and sugar in it ∙ Each drink also has a cost associated with it ∙ Your task is to find a subset of drinks of minimum cost to buy ∙ Such that all the drinks can be ”prepared” using the purchased drinks 26
  • 28. problem statement Definition Preparing a drink, means mixing two or more drinks in some proportion, yielding a new drink. The sugar and salt in this drink is the weighted mean of the sugar and salt contents of the constituent drinks. Note It is not necessary to prepare all the N drinks simultaneously. It is sufficient to be able to prepare all the N drinks independently. 27
  • 29. example Name Sugar Salt Cost A 4 2 1 B 3 3 5 C 2 4 10 Answer: Drink A and Drink B costing 11. Mixing them in 1:1 proportion gives Drink C 28
  • 31. solution Intuition ∙ Represent a drink with x mg sugar and y mg salt as (x, y) ∙ Visualize drink as a point on Cartesian plane ∙ Understand what mixing means in this setting ∙ Ignore cost aspect, for now just try to find a subset of drinks which can be used to prepare the remaining 30
  • 32. solution 1 2 3 4 5 1 2 3 4 5 C(2,4) B(3,3) A(4,2) Figure: Example 1 31
  • 33. solution 1 2 3 4 5 1 2 3 4 5 C(2,4) B(5,5) A(4,2) D(4,4) Figure: Example 2 32
  • 34. alice and bob play contact
  • 35. chn16i - alice and bob play contact Problem Statistics ∙ Total correct submissions - 69 ∙ Accuracy - 25.94% ∙ Number of submissions we made - 0 (fell short of time). 34
  • 36. brief problem statement ∙ Alice’s ’Vocabulary’ - set of strings SAlice = {A1, A2, . . . , An} ∙ Bob’s ’Vocabulary’ - set of strings SBob = {B1, B2, . . . , Bm} ∙ A game is played for each word Ai in SAlice ∙ In the jth iteration of the ith game, Bob uses a word from SBob that has a prefix of length j common with Ai. ∙ In a particular game, Bob cannot re-use a word he has already used in that game. ∙ Game ends when Bob has made |Ai| moves, or when Bob has no word left to make a move. 35
  • 37. brief problem statement ∙ Problem: Find the sum of maximum number of moves Bob can make for each of the n games. Constraints ∙ 1 ≤ n, m ≤ 105 ∙ 1 ≤ |Ai|, |Bi| ≤ 105 ∙ 1 ≤ ∑n i−1 |Ai| ≤ 106 ∙ 1 ≤ ∑m i−1 |Bi| ≤ 106 ∙ All strings consist of upper-case English alphabets ∙ All strings in SAlice are distinct, all strings in SBob are distinct 36
  • 38. strategies Aim Maximize the length of each game. Strategy 1 For jth move in a game, pick up any word from SBob which has prefix of length j in common with Ai. Will this work? Strategy 2 For jth move in a game, select an unused word from SBob with minimum prefix length ≥ j, common with Ai. This is the optimal strategy 37
  • 39. naive solution ∙ For each game i, maintain a list of words from SBob, with the option to mark words as ’used’. ∙ Calculate and store the lengths of prefixes of each word with Ai. ∙ At iteration j, pick a usable word that has minimum length of common prefix with Ai, such that the prefix length is ≥ j. Mark this word as used. ∙ If no such word is found, or if j > |Ai|, then the game has terminated 38
  • 40. time complexity ∙ For each game i, maintain a list of words from SBob, with the option to mark words as ’used’. O(n) iterations ∙ Calculate and store the lengths of prefixes of each word from SBob with Ai. O(|Ai| + ∑m j=1 |Bj|) time ∙ At iteration j, pick a usable word that has minimum length of common prefix with Ai, such that the prefix length is ≥ j. Mark this word as used. ∙ If no such word is found, or if j > |Ai|, then the game has terminated. Running time is O( ∑n i=1 |Ai| + n × ∑m j=1 |Bj|) = O(106 + 105 × 106 ) = O(1011 ) operations Verdict Time Limit Exceeded 39
  • 41. Can we do better? 40
  • 42. moving to an efficient algorithm Question Can we bring the running time down to O( ∑n i=1 |Ai| + ∑m j=1 |Bj|)? How? A hint to the approach For each Ai in SAlice, determine length of game by scanning a single word in Bob’s vocabulary. Another hint The alphabet size is fixed (only uppercase letters). Why would the problem author set this constraint? Everything points to a Trie-based approach 41
  • 43. moving to an efficient algorithm ∙ Hoard all Bob’s strings into a trie. O( ∑m i=1 |Bi|) = O(106 ) ∙ At each node, maintain total number of leaves reachable from that node. ∙ For each string Ai, search for Ai in trie - following certain constraints: ∙ If there are nx strings at node x, one of them has to be used at that node ∙ Greedy strategy - use string that overlaps as little as possible with search path 42
  • 44. an example to demonstrate the approach Bob’s Vocabulary ∙ ant ∙ bat ∙ bestow ∙ bested ∙ besxyz ∙ bust ∙ cat Alice’s current word : bestow https://www.cs.usfca.edu/ galles/visualization/Trie.html 43
  • 45. final algorithm Algorithm 1 Determining Length of a Game 1: glen ← 0, avl ← |Ai|, j ← 0 2: t ← root of trie 3: while j < |Ai| do 4: if avl = 0 then 5: break 6: if jth character of Ai not found in trie then 7: break 8: t ← node of trie storing jth character of Ai 9: avl ← min(avl-1 , paths from t -1) 10: glen ← glen + 1, j ← j + 1 11: glen is the maximum game length 44
  • 46. final algorithm Running Time O( ∑n i=1 |Ai| + ∑m j=1 |Bj|) i.e. approx 2 × 106 operations Verdict Accepted 45
  • 47. attribution This presentation has been made using the LATEX theme mtheme Get the source of this theme and the demo presentation from github.com/matze/mtheme The theme itself is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. cba 46
  • 50. useful material Links to Problems (ACM-ICPC Asia Chennai 2016 Regionals) Problem Link Voting Fraud CHN16G ACM ICPC World Finals Accomodation CHN16F Birthday Pizza Party CHN16C Mancunian Candidate Master Forever CHN16B Alice and Bob Play Contact CHN16I Applet Demonstrating CHN16B (developed by P.R. Vaidyanathan) 49