Archive for the ‘Programming’ Category
Where are We Going ?
August 31, 2008ICPC 007 !! B-)
December 30, 2007The Amrita University Organised the ICPC @ its Amritapuri Campus, Kerela.
Our Team: CSpirit
Members : Me, Shankar, Siddharth (Shankar is the new member of the team due to unknown reasons !!)
Let me start with the Online Round:
We did the online round well but still i thot we were slow. We were supposed to use one login per team but still 3 of us were in our respective homes. We decided that I shd login and do the submissions and stuff but hell broke loose when i was unable to even view the mooshak page !! Sidd took the job and pasted all the problem statements in rafb.net. I submitted for 1 of the problem to get AC in 55th minute. 1st AC !! habba !!… “Wot are u guys doing ?”. “sidd: I am trying B da.. Try anything else”. I started doin the other problem (not B). The prob was to “represent prime numbers in words”. Sidd got AC for prob B by 1.15 or something. By the time i finished coding, shanky was also done. I was confident.. so Sidd submitted my code to get AC !! Hurray.. We are all Done !!
We came in 9th place. We were the only team to get AC(Accepted) for all the 3 problem in 1 shot with no penalties :D. They selected 2 Teams from each college. So The other team from m y class was not selected :(. (we had even got tickets) . The Juniors team got thro.
Regionals:
The Train Trip was not bad. The Amritapuri guys were very courteous. They received us in station even thought we didnt ask for a pick up. The hostel room given to us was very big. nice room. nice washroom. nice place. They provided us with free supply of mineral water bottles! We went to the college. They gave us Internet Facility, which we used to some extent. The Food was not that great though.
Another Notable thing about the college was that, wherever u go, the place would hv been labelled “Boys” and “Girls” in 2 sides. Be it the lab, canteen, auditorium. Is the college is very strict wrt to boys and gals…? (atleast the banners not there in my coll !!) . I knew I was wrong later. U cant see only boys or only gals doin something: Be it eating in the canteen or taking care of some part of the event.
I didnt talk with many of other ppl. except for ThreeAces and Chocolat from CEG. and Ckrackers from MIT-our coll !! CEG seniors were very free going. They said they organise some of events @ kurukshetra. Said they would come to Samhita too. I knew Anusha and Aruna of Chocolat from ICPC-2006 and had known them primarily thro the Internet. In Kerela, talked with them in real-time. We even took a photo.
I took Camera to kerela to take photos.. I forgot to take camera to all the places and ended up without any photos.. This is the only photo i have now.
In Kerela, most of the gals were better than tamil gals esp. manyfold better than my college ! hope u undstd…
-> :(( … When we were in the internet lab, some gal volunteers were guiding us with getting print outs. We wished these gals dont come to the contest for obvious reasons !! One of them said us that Prasanna (aka Thala, Singam, Singa-Kutti …) would be delivering a speech. Thala was shivering all the time giving speech. After the speech, He was able to identify me to my surpise. He also Identified Shankar…coz they talked in Kanpur.
Prasanna: Thala…
Shankar: <mum>
Vijay: macha, wot is this, prasanna is takin to u. ur not talking ?
Shankar: <mum>
After some time,
Vijay: Y u didnt talk to prasanna? Clg Gals kitta than olunga pessa matta … Maintaining Ur Taaru Maaru Geth even with Prasanna. ?
Shankar: Dei.. avanllam range da..!
Vijay: He called u thala da !!
Shankar: Avan enna ottaran da.. In Kanpur, I asked him “Wen are u going to become target?”…adhunala than ippo enna Kalaikarthuku apdi sonnan da.
Vijay: Edo solra.
During our stay, we were late to all the events, from arriving at the station, goin to breakfast, lunch, dinner, attending speech , … getting bus for departing … We missed the Kaliripattu performance coz we slept !!
Practice Contest:
Did very very silly mistakes which drank our time. like
1) Trying to find the bug in prime function even without calling it !
2) counting no. of days in the year as 355.
3) Got confused with a simple if else statement involing &&, || operators
At the End of the Practice Contest… we were not in the first page of the rank-list… that too with easy questions. ofcorz it would hv been easy for everyone ! Chocolat was very fast and they were in 5th position. We were wondering may be we shd hav practiced together before. I remembered Anusha tellin me that they attended all contest together. We knew that they gave solutions for practice problems below the qns themselves only after the end of the contest !! Sidd said “when we solve the problems which chocolat solves in the same time penalty.. we would surely get gud position” haa.. but that might not be that easy. Sidd: “And ofcorz we should solve one more problem !!”… hmm pakkalam…
BackWater Boating:
The Amrita ppl also took us for Boat Riding along Back Waters. It was not bad.. it seemed that the scene repeated itself: coconut trees, fish nets, houses. The co-ords came to our cabin and asked to sing. The guy was seein just me and tellin to sing… reason being all others dont even seemed to hear to him. Jnr. Vikram said me “y dont u sing ?”… “Naan padina ellarum thannila kuthichiruvanga da!!”… “Super idea, senior, Ella teamum thannila villunthutta… neenga first vanthurunga, nanga second.”… lol.
The Main Contest :
They gave username and password for linux only with the Qpaper.. Ahhh… which meant I hv to spend the contest time for typing headers and stuffs :(…
We had decided to split the Qns and so that the easiest problem can be identifed soon by one of us. There were 8 problems. The first prob i read looked easy.. So i started… After some debugging, I got AC for it in 30 min. When we looked at the rank list. XTC++ was first solving each of the problems in 10 min. Chocolat was second with almost same time. (semma fast!! ). Sidd had hand coded that other problem. He started typing it.. while me and Shankar read the other problems. In more than 5 minutes, he finished it and submitted to get WA.. !! boo !! sidd: “Dei.. WA da chaaa” Others: “seri.. porumaiya par ethavadu thappu panni irrupa”.
After few minutes of debugging.. he identified his stupid bug and then got AC. That was our final AC. Shankar had finished one of the problems involing two balls rolling over and under irregular plane. He was struck up with some bayangaramana case. Sidd and Shanky was thkin over it. At that time, I was coding a Min. Spanning Tree for one of the problems. After much struggle, I was able to code it out. Sidd and Shanky decided to skip the ball rolling prob and switch to another problem which was simple but involved careful handling of many cases. They were hand-coding it. Tho I got correct ans for Sample I/O for the min. spanning tree prob,,, I felt something was missing something. I got WA when I submitted. I got print out and Sidd and Shank Coded the prob they were doing. I helped them out in finding out beautiful no.s which was part of that problem and also in debugging some logical error in it.
I left the minimum. Spanning tree prob and went to simulation prob. which involed rotating a cube in various directions. I was able to handcoded it in a short time. When Sidd and Shanky gave up on their prob when only 10.00 min was left.. i started coding the simulation… The time was not enof for me.. but i got some output in some 20 min. after the contest ended.. I would hv done that had i started on that long bk !
We tried all the problem except a couple of them. When the contest ended, We were in the 22nd place. Our juniors had Solved 3 probs(
). They were in 15th place.
Ranklist can be found here.
We talked with prasanna after the contest. We found that bayangaramana case for ball-rolling problem is not present and that such a case is not possible as per the problem statement.. Alas.. !! May be we should hv tried submitting it without that case.
Prasanna said for that min. spanning tree problem.. we should apply shortest-path-algo after finding the min. spanning tree.. I got that only after some thinking. Prasanna had set 4 of the contest questions. He was also one of the judges.
Post Contest Analysis in the hostel showed us that we would hv got AC for 5 of the problems if we had worked little more smarter. The other 3 required us to hv more knowlege on Algos and only one or two teams solved them. Much more to learn about teamwork, co-operation and stuffs.
Symps this sem
September 23, 2007I did attend some symposiums this semester. I got first prize in debugging or programming in all of them. Now wot does this mean ? This means one or more of the following :
1) I cheated.
2) In all the places they asked the qns for which i already know the answer.
3) I had a gud team mate .
4) Its an event which is a part of one of the corners of the Binomail Distribution !!
5) man, i am gud at programming !!
The Colleges i attended tech symposiums are Sairam, Crescent, SSN-Paradigm and also Juggernaut which took place in my college !
I wont say i learn a lot by attending these… But I do see lot of ppl [:D]… and most importantly i learnt more things that wot i would learn by attending classes this semester…
C ya sooon, Byee ! ![]()
Juggernaut sep07
September 23, 2007The Computer Society of MIT started conducting Juggernaut from this September as a monthly campus event. The event includes several rounds including Puzzles, problem solving, algorithms(for circuit brchs), programming(for circuit brchs), core tech qns(for mech stream), computer designing (for mech stream). The Chairman told me while asking for comments about the event “Some Third yr student suggested doing programming contests thro Computer Society to Ramgopal and he approached me regarding this and thats how we started this event”. He did not know then that “Some Third yr student” was me !! :D.
Ok Coming to the event, It was very nice having 3 rounds. I and Suryanarayanan were a team and we completed all the 3 rounds and became Winners of Juggernaut sep07 !! hehe…. Another thing i would always remember bout the event is about the teamname. Initially we had given a team-name “Anything for Namitha” cool ha… The co-ords said durin round 1 to change the team name or else they may disqualify us !!
Thus, We were already famous before the whole event started…. so we changed our teamname to “code-freaks”…. hmm… In the finals we beat Siddharth’s team. They had sufficient amount of time penalty to become runner ups !!!
I give here the questions and our solutions of those qns we solved during the final programming round of the event:
Password Cracking :
Mario is a student of Final Year IT. Mario is a typical gethu MIT student who rarely attends class.Now he’s so much worried over the issue of Marks for attendance. His attendance marks would definitely be zero only.If he somehow manages to get marks in it he’ll clear the final year.
So he thinks of breaking into the COE office and changing the attendance marks in the computer there.The computer that holds the marks of students are placed in a secured room which no one can break into. The computer wont allow the third time wrong entering of the password and would raise an alarm and would get caught.The only way to get into is through the entrance which is protected by a security computer.Only after typing the password in the keyboard there one can enter the room.
The password cant be guessed or hacked through any means.The only way is to bring out the password from the hands of the COE officer,Mr.Paritchai Vendhan.The COE officer has a low memory.So he has a list of passwords in hand stored in a file .Once in fifteen days he selects one word from the list and sets as the password.Mario somehow managed to get that password file consisting of words N > 3 . But the only problem is that he has to get that correct password from it.So he devised one method.
Mario gifted Mr.Paritchai Vendhan a pen as a gift which was coated with a fluorescent marking material.When he took the pen in his hands ,his hands were stained with that invisible fluorescent marking material.What ever objects he touched were stained with that material which is invisible under normal light but can be viewed under a fluorescent light.Without knowing these he typed his password (with his stained hands )and entered the room . That night Mario came to that Computer room and he used a fluorescent light to look through the keys which were stained with that material,(ie) the keys that the COE officer used to type the password.As everyone knew our Mario is strong enough in action & adventures but very poor in logics and computers.
So with that password file in hand and the key strokes that he could decipher from the keyboard , now help Mario in finding the password and help him clear the final year,after all he’s your senior.It is noted that all passwords are in lowercase and numbers can also appear.
Input:
Input consists of T,the no of test cases ,where T<=10
Each test case consists of N , where 3<N<40 followed by N words each on a new line.
Each word doesnt exceed 15 characters.
K , no of keys that has a stain impression on it followed by K keys on a single line.
Output :
It must print one word for each test case each on a separate line.
If no words are matchin print NOP
if more than one words match print each word separated by a space on a single line in ascending order
Sample Input:
2
5
monkey
honey
donkey
sad
honest
6
ykonme
4
are
busy
mine
worse
4
mtbi
Sample Output:
monkey
NOP
Sum Of Perfect Cubes :
A perfect cube is an integer whose cube root is an integer ie a whole number . Eg : 1 , 8 , 27 , 64 , 125 are perfect cubes .
You are given an int low and an int high . You have to find the sum of all perfect cubes that lie between low and high also including low and high .
NOTE : Here we have sizeof(int) as 4 since we are using 32 bit rep.
CONSTRAINTS :
-
The first line in the input file contains no. of test cases .
-
Each test case is separated by an empty line.
-
Each test case satisfies the following conditions :
-
Value of low(first line) ranges from 2 to 2^31-1 both inclusive.
-
Value of high(second line) ranges from low to 2^31-1 both inclusive.
-
The output should contain one line for every test case.
-
Each line in the output must be the sum of all the perfect cubes cubes in the given range.
Sample Input :
3
1
1
7
63
7
65
Sample Output:
1
35
99
Graph Printing :
A scientist needs to analyze his research based on the graphical representation of his experiment’s output. All the results need to be plotted in a two dimensional graph of which X-axis and Y-axis represents some parameter. The graph will contain only three symbols as follows:
“/ “– Represents a unit increase in the previous value of Y-axis
“_“- Represents no change in the previous value of the Y-axis.
“\“- Represents a unit decrease in the previous value of the Y-axis.
(Quotes for clarity only)
X-value increases uniformly at the rate of one unit.
You are provided with the sequence of these symbols based on the result. Your task is to print the representation of the graph with X and Y value starting from 0. X-value increases by one for each Y-value. Sample input and output is given below.
Constraints :
-
First line of input contains no. of test cases.
-
Each test case has a single line containing either of the 3 characters ‘_‘,’/’and ’\’.
-
Each test case has between 2 characters and 20 characters both inclusive.
-
Ouput should contain the representation for each test case.
Sample Input:
4
////___\\\\
\\\/\/\
/_\_/_\
___///
Sample Output:
___
/ \
/ \
/ \
/ \
\
\
\/\/\
_ _
/ \_/ \
/
/
___/
SOLUTION TIME!!!
PASSWORD CRACKING
The problem can be reduced to : From a given list of words W, find the words which contain all but only the letters in the word L. Many ways to solve this problem. One way is to use 2 flag arrays for each of the words: 1 for letters of size 26 and 1 for numbers of size 10. The index in the flag arrays corresponding to a word is 1 if that letter or number appears in the word.
Have a flag array pair for each of the words in W and one flag array pair for the word L. Output all words in W whose flag array pair is same as flag pairs corresponding to L. if none of them exist, output NOP.
SUM OF PERFECT CUBES
A Brute Force Approach could solve this problem.
long long i;
for(i = 1; i*i*i <= high; i++)
{
if(i*i*i >= low) sum += i*i*i;
}
print sum
But If u Belive u are decendents of ramanujam try to solve d prob in o(1) mathmatically !!
GRAPH PRINTING
With atmost 20 characters, the graph cannot go away from horizontal range 0-20 and vertical range of 20 to -20. Wot we can do it declare an array of size 50*25 say… arr[50][25]. Start plotting ur graph from the point arr[25][0]…
After that for each character in the given string S…. S[i] ull plot it in the graph at the position arr[j][i]… j is determined by the graph positon for the character S[i-1] and the character S[i-1] itself. A little thot on this is the only thing left which is left as exercise for the reader !!
|
|
Abacus PC
May 9, 2007We went to attend Abacus 2k7 @ CEG…
I would say… of all the tech fests i attend, i like Abacus the most…
It was basically due the type of events which take place…. basically related to programming, problems ,puzzles and stuff… and ofcourse the quality….
And it takes place for 3 days…. hmm.. wot else could a guy like me ask for….
I enjoyed all the events, i attended wid my friends…
We got first prize in programming event…
I took these pics when we were busy during the finals !!!
We got interview call from Efficient Frontiers
We attended the interview and did well… they were ok about us.. then told us that internship wont be possible unless its atleast 3months… or we do part-time after hols….. so… the possibility… was chucked out!!
The guy later mailed us sayin.. that they already got interns from IITs… so our case can be considered later and to keep in touch… grr…
ICPCs 2006
May 9, 2007ok.. ppl… long time..
and many things have happened…
I attened my first ICPCs last december…The prelims…
our team name : CSpirit
Prelims was not a problem for us… since we were able to solve few problems during both the Prelims of IIT-K and Amrita… and hence we were qualified for the regionals…
IIT-Kanpur
We attened the ICPC both @ Kanpur (IIT)
and Coimbatore(Amrita Univ)… I would say that we shd have attened only at coimbatore… considering our skills then… but still i guess we did learn something… :)…
Trip to Kanpur was a different one… never had I travelled so north ever b4…
Trip was basically full of eating, sleeping and forest(code-word for mokkai) ….
We did open some algo books during the trip.. like last min. study during exams … it was last min… preperation for contests !!!
Another thing which we cant forget was trouble we faced wid hermaphrodites while going thro andhra !!
In pic: The comp we used during the contest!!!
Kanpur was nothing more than a town i would say… almost all building were painted just in front… the sides were just bricky !! IITK was awesome… The climate was cool…(i mean really cool.. around 5 or 6 *C during nights) i dreamt that type of climate in chennai…!!I was kinda always optimistic bout what we could do during the contest… the other guys were not much appreciative in words bout that… So where did we end up in the contest… We did spend the 4 hours hours contest time trying to solve problemS… but didnt solve even 1 !! did we come 2000 kms for this !!:((…. We shd have concentrated on solving one problem at a time rather than splitting the problems… we cudnt solve even the easiest of the problems… :(…. I did came to know some new ppl… like Prasanna , NITT who got the first place.. Also came to know our Seniors from CEG… who accompanied us during the return trip… Same eating, sleeping and forest during the return journey… So thus ended our tour of ~4000 Kms.. with a honourable mention!!
link: http://www.cse.iitk.ac.in/users/acm/
Amrita Univ
About a week later, we were off to Coimbatore… It was kinda more relaxing for us… the journey was during night and was just 1 night… which means one sleep and ull be there @ the place.. !! wow !! :p… Another thing was that, ppl speak Tamil in Coimbatore!! so was quite happy….
The Climate was cool… not as cool as Kanpur.. but stay @ Chennai for bout a week… made me to feel that way… This time i was always stressing on the guys to be +ve !!! We knew we were not that bad to solve 0 probs even here !!!
We decided to solve 1 prob at a time…
The Practice Sessions were horrible… We got freakin responses from the judge during practice sessions… Compile Errors and TLE for no reason… We were kinda feelin Cryptic bout the Judge…..and hoped it doent happen that way during the contest.. We were discussing 1 of the practice probs which we coudnt solve…. we were then learning new technique of backtracking to solve problems…. Kinda most used technique to solve constraint based problems and puzzles… and it helped us a lot during the contest….
It Started… and going thro all the questions.. at first we thot… that we could solve one or two… but within a couple of hours … we had solved 2 problems…
It really gave us a boost… I wont forget to mention we had refreshments during the contest !! :D…. And after being busy for 3 problems, i was kinda havin rest… and I ate Srivathsan’s cake & biscuits along wid mine.. !!! poor guy.. was busy wid other problem.. !!
Just b4 the ranklist was freezed 1/2 hr b4 the contest… we were 2nd the Ranklist.. just after CodeMonkeys !! wow.. we cudnt just blive it.. We have a chance of going to finals if we maintain that postion till the end of the contest !!! :p… But we were very happy that we cud do this much especially after the Kanpur thingy…
When the results were announced.. we were in 8th place !! :o…
So after many rejudging and stuff we were put in 8th place.. !! We were not really sad or nything… we cud solve 5/7 probs…
link : http://www.amrita.edu/icpc/2006/Standings.html
