-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlog.txt
225 lines (225 loc) · 23.2 KB
/
log.txt
1
:wolfe.freenode.net NOTICE * :*** Looking up your hostname...:wolfe.freenode.net NOTICE * :*** Checking Ident:wolfe.freenode.net NOTICE * :*** Couldn't look up your hostname:wolfe.freenode.net NOTICE * :*** No Ident response:wolfe.freenode.net 001 adlogbot :Welcome to the freenode Internet Relay Chat Network adlogbot:wolfe.freenode.net 002 adlogbot :Your host is wolfe.freenode.net[193.10.255.100/6667], running version ircd-seven-1.1.4:wolfe.freenode.net 003 adlogbot :This server was created Thu Sep 22 2016 at 20:50:16 UTC:wolfe.freenode.net 004 adlogbot wolfe.freenode.net ircd-seven-1.1.4 DOQRSZaghilopswz CFILMPQSbcefgijklmnopqrstvz bkloveqjfI:wolfe.freenode.net 005 adlogbot CHANTYPES=# EXCEPTS INVEX CHANMODES=eIbq,k,flj,CFLMPQScgimnprstz CHANLIMIT=#:120 PREFIX=(ov)@+ MAXLIST=bqeI:100 MODES=4 NETWORK=freenode KNOCK STATUSMSG=@+ CALLERID=g :are supported by this server:wolfe.freenode.net 005 adlogbot CASEMAPPING=rfc1459 CHARSET=ascii NICKLEN=16 CHANNELLEN=50 TOPICLEN=390 ETRACE CPRIVMSG CNOTICE DEAF=D MONITOR=100 FNC TARGMAX=NAMES:1,LIST:1,KICK:1,WHOIS:1,PRIVMSG:4,NOTICE:4,ACCEPT:,MONITOR: :are supported by this server:wolfe.freenode.net 005 adlogbot EXTBAN=$,ajrxz WHOX CLIENTVER=3.0 SAFELIST ELIST=CTU :are supported by this server:wolfe.freenode.net 251 adlogbot :There are 142 users and 87749 invisible on 29 servers:wolfe.freenode.net 252 adlogbot 35 :IRC Operators online:wolfe.freenode.net 253 adlogbot 13 :unknown connection(s):wolfe.freenode.net 254 adlogbot 53790 :channels formed:wolfe.freenode.net 255 adlogbot :I have 9767 clients and 1 servers:wolfe.freenode.net 265 adlogbot 9767 10146 :Current local users 9767, max 10146:wolfe.freenode.net 266 adlogbot 87891 92341 :Current global users 87891, max 92341:wolfe.freenode.net 250 adlogbot :Highest connection count: 10147 (10146 clients) (794314 connections received):wolfe.freenode.net 375 adlogbot :- wolfe.freenode.net Message of the Day - :wolfe.freenode.net 372 adlogbot :- Welcome to wolfe.freenode.net in Stockholm, SE.:wolfe.freenode.net 372 adlogbot :- Thanks to http://nordu.net/ for sponsoring:wolfe.freenode.net 372 adlogbot :- this server!:wolfe.freenode.net 372 adlogbot :- :wolfe.freenode.net 372 adlogbot :- WOLFE, GENE [1931-]. Prolific writer of short stories and:wolfe.freenode.net 372 adlogbot :- novels. His best-known work is the multi-volume novel The:wolfe.freenode.net 372 adlogbot :- Book of the New Sun. He has won multiple awards including:wolfe.freenode.net 372 adlogbot :- the Nebula Award, the World Fantasy Award, The Campell:wolfe.freenode.net 372 adlogbot :- Memorial Award and the Locus Award. He was awarded the World:wolfe.freenode.net 372 adlogbot :- Fantasy Award for lifetime achievement in 1996.:wolfe.freenode.net 372 adlogbot :- :wolfe.freenode.net 372 adlogbot :- Welcome to freenode - supporting the free and open source:wolfe.freenode.net 372 adlogbot :- software communities since 1998.:wolfe.freenode.net 372 adlogbot :- :wolfe.freenode.net 372 adlogbot :- By connecting to freenode you indicate that you have read and:wolfe.freenode.net 372 adlogbot :- accept our policies as set out on http://www.freenode.net:wolfe.freenode.net 372 adlogbot :- freenode runs an open proxy scanner. Please join #freenode for:wolfe.freenode.net 372 adlogbot :- any network-related questions or queries, where a number of:wolfe.freenode.net 372 adlogbot :- volunteer staff and helpful users will be happy to assist you.:wolfe.freenode.net 372 adlogbot :- :wolfe.freenode.net 372 adlogbot :- You can meet us at FOSSCON (http://www.fosscon.org) where we get:wolfe.freenode.net 372 adlogbot :- together with like-minded FOSS enthusiasts for talks and:wolfe.freenode.net 372 adlogbot :- real-life collaboration.:wolfe.freenode.net 372 adlogbot :- :wolfe.freenode.net 372 adlogbot :- We would like to thank Private Internet Access:wolfe.freenode.net 372 adlogbot :- (https://www.privateinternetaccess.com/) and the other:wolfe.freenode.net 372 adlogbot :- organisations that help keep freenode and our other projects:wolfe.freenode.net 372 adlogbot :- running for their sustained support.:wolfe.freenode.net 372 adlogbot :- :wolfe.freenode.net 372 adlogbot :- In particular we would like to thank the sponsor:wolfe.freenode.net 372 adlogbot :- of this server, details of which can be found above.:wolfe.freenode.net 372 adlogbot :- :wolfe.freenode.net 376 adlogbot :End of /MOTD command.:adlogbot MODE adlogbot :+i:adlogbot!~adlogbot@223.231.18.48 JOIN #wcalgo4:wolfe.freenode.net 332 adlogbot #wcalgo4 :Web Club Winter Mentorship 2016:wolfe.freenode.net 333 adlogbot #wcalgo4 vilas_m!~vilasnitk@202.12.80.10 1481195421:wolfe.freenode.net 353 adlogbot @ #wcalgo4 :adlogbot Pratik Ashwin Rohan__ ankit_ PSL shamitha Harichandana Sai tushaar @vilas_m:wolfe.freenode.net 366 adlogbot #wcalgo4 :End of /NAMES list.:Ashwin!2f1dc4dd@gateway/web/freenode/ip.47.29.196.221 PRIVMSG #wcalgo4 :nope:Rohan_!75d943fb@gateway/web/freenode/ip.117.217.67.251 JOIN #wcalgo4:Pratik!6a4f92de@gateway/web/freenode/ip.106.79.146.222 PRIVMSG #wcalgo4 :I too solved some of them:PSL!01bb8f9c@gateway/web/freenode/ip.1.187.143.156 QUIT :Ping timeout: 260 seconds:Rohan_!75d943fb@gateway/web/freenode/ip.117.217.67.251 PRIVMSG #wcalgo4 :I tried some problems:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :It's fine. But try to finish them soon and ping us if you have some trouble :) :vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :When you are coding on competitive programming platforms, one thing to realise is that - the inputs and outputs are dealt with in seperate files. :vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :What I mean to say is, the input is read from the stdin file and the output is written stdout file by default.:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :This gives us a really good advantage. Can anyone guess what it is?:Ashwin_!2f1dc4dd@gateway/web/freenode/ip.47.29.196.221 JOIN #wcalgo4:Sai!9d31fdbe@gateway/web/freenode/ip.157.49.253.190 PRIVMSG #wcalgo4 :If we give all the input at once but the processing takes time... The input can be stacked:Rohan__!75d943fb@gateway/web/freenode/ip.117.217.67.251 QUIT :Ping timeout: 260 seconds:vilas_m!~vilasnitk@202.12.80.10 TOPIC #wcalgo4 :Session 1. Today's logs: https://github.com/adeepkit01/logger/blob/master/log.txt:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :Yea, so basically let's say in a problem, there are several input test cases. Your code will look something like :vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :cin>>T; while(T--) { //your code }:Ashwin!2f1dc4dd@gateway/web/freenode/ip.47.29.196.221 QUIT :Ping timeout: 260 seconds:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :So here in this case, you can print the output required immediately after it is calculated for a given test case. You need not wait to read all input to print the output. :vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :Next:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :I have seen many of my batchmates do this :P Do not print redundant text such as "Enter the number of test cases", "Enter the input", "The output is:" and so on. :vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :Your output file will be compared with the correct answer output file character by character. So printing such statements will cause a wrong answer.:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :The running time of your codes is also really important.:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :Typically, you will get TLE - Time limit exceeded if your code run time is over a few seconds (the limit varies according to the website/problem) :ankit_!~ankit@223.231.18.48 PRIVMSG #wcalgo4 :and language :vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :So you have to be careful and make sure the algorithms you use are efficient. :vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :What language do you guys code in? :Pratik!6a4f92de@gateway/web/freenode/ip.106.79.146.222 PRIVMSG #wcalgo4 :mostly C or C++:Ashwin_!2f1dc4dd@gateway/web/freenode/ip.47.29.196.221 PRIVMSG #wcalgo4 :same here:Sai!9d31fdbe@gateway/web/freenode/ip.157.49.253.190 PRIVMSG #wcalgo4 :c++ or python:Rohan_!75d943fb@gateway/web/freenode/ip.117.217.67.251 PRIVMSG #wcalgo4 :I know c:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :Others? :vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :The run time and time limit for each question depends on the language as well.:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :For example, as Python, Java codes are much slower than C, time limit for Python is set five times higher than C/C++, and for Java, it is twice as that of C/C++.:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :Even though this relaxation is provided, it usually isn't enough to compensate for the slower languages. So it's better to use C/C++.:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :If you guys are working on C++ (which should be preferred over C. We shall see later why), try to replace all cin/cout statements with the corresponding printf/scanf statements as the latter is much faster:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :Any doubts so far? :Sai!9d31fdbe@gateway/web/freenode/ip.157.49.253.190 PRIVMSG #wcalgo4 :no:Rohan_!75d943fb@gateway/web/freenode/ip.117.217.67.251 PRIVMSG #wcalgo4 :No:ankit_!~ankit@223.231.18.48 PRIVMSG #wcalgo4 :about the scanning part, it will be faster if you make your own custom scanner based on getchar_unlocked :Pratik!6a4f92de@gateway/web/freenode/ip.106.79.146.222 PRIVMSG #wcalgo4 :No:Ashwin_!2f1dc4dd@gateway/web/freenode/ip.47.29.196.221 PRIVMSG #wcalgo4 :No doubts:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :Next, data types.:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :It's always better to declare integers as long long int, floating point numbers as long double etc in case the range of input ( typically, the range of input will be available in the question ) is quite large:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :The range of int is around 10^9 while the range of long long int is around 10^18:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :Changing int to long or long long int will not affect the run time of your code much, so there is no harm in doing so if you are unsure whether you need long long int or not. :vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :Whenever you declare arrays of large size, say around 10^5 or so, make it a point to declare them globally. :vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :Else, it will cause segmentation faults.:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :Even while declaring them globally, make sure the size does not exceed 10^7.:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :If you need an array of size more than that, than it probably means you will need a better algorithm. :vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :Now, coming to the run time of your code.:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :Typically in C/C++, approximately 4 * (10 ^ 8 ) operations can run in 1 sec. :vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :The time limit and the input size of the problem will give you an idea of the complexity of the algorithm required :vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :For example, if the input size range is <= 10^4 for a time limit of 1 sec, it probably means an O(n^2) solution is required.:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :Now here is another trick to use while coding online.:Ashwin_!2f1dc4dd@gateway/web/freenode/ip.47.29.196.221 PRIVMSG #wcalgo4 :what's "O(n^2) solution":vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :Big-oh notation as we call it, gives an idea of the run time of an algorithm in terms of the input size:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :So, O(n) implies, the code will run in about n steps, where n is the size of the input:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :for example, say you have a single for loop from 1 to n, where n is the size of the input array. :vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :This runs in O(n) time:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :Similarly, a nested for loop:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :for(i=0; i<n; i++) { for(j=0; j<n; j++) { // code } } runs in N*N steps, correct? :Ashwin_!2f1dc4dd@gateway/web/freenode/ip.47.29.196.221 PRIVMSG #wcalgo4 :right:Pratik!6a4f92de@gateway/web/freenode/ip.106.79.146.222 PRIVMSG #wcalgo4 :Can you give an example for input size and time limit for O(log(n)) or O(nlog(n)) solution?:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :Lets take the for loop, for(i=1; i<N; i*=2) { code } :vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :Can anyone point out why the above for loop runs in O(log N) ? :Sai!9d31fdbe@gateway/web/freenode/ip.157.49.253.190 PRIVMSG #wcalgo4 :first loop it will run n times:Ashwin_!2f1dc4dd@gateway/web/freenode/ip.47.29.196.221 PRIVMSG #wcalgo4 :The variable i runs as 1,2,4,... 2^n:Sai!9d31fdbe@gateway/web/freenode/ip.157.49.253.190 PRIVMSG #wcalgo4 :then it will run for n/2 times:Sai!9d31fdbe@gateway/web/freenode/ip.157.49.253.190 PRIVMSG #wcalgo4 :ans so on..:Sai!9d31fdbe@gateway/web/freenode/ip.157.49.253.190 PRIVMSG #wcalgo4 :and*:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :There is only 1 for loop there, @Sai :) :Sai!9d31fdbe@gateway/web/freenode/ip.157.49.253.190 PRIVMSG #wcalgo4 :ohh sorry :vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :So like all problems :P, let's say the code runs in x steps. :vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :At the beginning of the xth step, what is the value of i? :Ashwin_!2f1dc4dd@gateway/web/freenode/ip.47.29.196.221 PRIVMSG #wcalgo4 :2^x:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :Exactly! :):vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :So, 2^x < N. Hence, x < log N ( to base 2 ), correct? :Pratik!6a4f92de@gateway/web/freenode/ip.106.79.146.222 PRIVMSG #wcalgo4 :Yeah:Sai!9d31fdbe@gateway/web/freenode/ip.157.49.253.190 PRIVMSG #wcalgo4 :yeah:Ashwin_!2f1dc4dd@gateway/web/freenode/ip.47.29.196.221 PRIVMSG #wcalgo4 :I was closer [19:43] <Ashwin_> The variable i runs as 1,2,4,... 2^n :):vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :So, we can tell the worst case time complexity is O(log N) :vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :Any doubts so far? :Sai!9d31fdbe@gateway/web/freenode/ip.157.49.253.190 PRIVMSG #wcalgo4 :No:Ashwin_!2f1dc4dd@gateway/web/freenode/ip.47.29.196.221 PRIVMSG #wcalgo4 :no:Pratik!6a4f92de@gateway/web/freenode/ip.106.79.146.222 PRIVMSG #wcalgo4 :NO:Rohan_!75d943fb@gateway/web/freenode/ip.117.217.67.251 PRIVMSG #wcalgo4 :No:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :Next :vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :Due to the limited time available during contests, it is a pain to identify and type all header files required in your program.:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :Instead of doing that, include a single header file called bits/stdc++.h in your programs (for C++ only). :vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :This header file includes every other header file in the C++ standard library and thus, there is no need to include any more header files.:Ashwin_!2f1dc4dd@gateway/web/freenode/ip.47.29.196.221 PRIVMSG #wcalgo4 :Doesn't that affect time complexity?:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :No. The compile time of the program will be affected a bit due to this, but run time will not be affected. :vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :Only the run time will be considered on Online Judges :Ashwin_!2f1dc4dd@gateway/web/freenode/ip.47.29.196.221 PRIVMSG #wcalgo4 :Ok got it:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :So now we come to STL :D :vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :One of the main reasons why C++ is preferred over C in competitive programming.:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :Does anybody know what it stands for? :Ashwin_!2f1dc4dd@gateway/web/freenode/ip.47.29.196.221 PRIVMSG #wcalgo4 :STereoLithography?:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :Haha, not really ;) It stands for Standard Template Library:Ashwin_!2f1dc4dd@gateway/web/freenode/ip.47.29.196.221 PRIVMSG #wcalgo4 :xD:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :Why do we use it? So that we can spend more time trying to devise a logic to solve a question than wasting much time for the implementation.:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :STL provides ready-made functions and containers which makes our code look neat:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :What sorting and searching techniques are you guys aware of? :Pratik!6a4f92de@gateway/web/freenode/ip.106.79.146.222 PRIVMSG #wcalgo4 :bubble sort, selection sort, quick sort and mergesort:Sai!9d31fdbe@gateway/web/freenode/ip.157.49.253.190 PRIVMSG #wcalgo4 :Linear and Binary search:Ashwin_!2f1dc4dd@gateway/web/freenode/ip.47.29.196.221 PRIVMSG #wcalgo4 :bubble,selection; binary:Sai!9d31fdbe@gateway/web/freenode/ip.157.49.253.190 PRIVMSG #wcalgo4 :I don't know quick sort though:tushaar!~tushaar@47.29.215.238 PRIVMSG #wcalgo4 :Bubble, Selection, Merge, Insertion, Quick, Heap and Shell; Binary, Linear:Rohan_!75d943fb@gateway/web/freenode/ip.117.217.67.251 PRIVMSG #wcalgo4 :Bubble,selection, binary:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :Can you guys point out the time complexity for all of them? :tushaar!~tushaar@47.29.215.238 PRIVMSG #wcalgo4 :Bubble - n*2 = Selection = Insertion; Quick = n*2 (Worst) = nlgn (Best and Avg); Merge - nlgn; Shell - n*2:tushaar!~tushaar@47.29.215.238 PRIVMSG #wcalgo4 :Heap - nlgn:tushaar!~tushaar@47.29.215.238 PRIVMSG #wcalgo4 :Binary - lg n (For sorted array only); linear - n:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :Awesome tushaar :) So we ll not go into the depths of deriving the complexity for all of these, but do remember them. :Ashwin_!2f1dc4dd@gateway/web/freenode/ip.47.29.196.221 PRIVMSG #wcalgo4 :ok:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :Instead of implementing an entire sort function while coding in online contests, You could just use sort(a,a+n) to sort the array a of n elements in the ascending order. :Sai!9d31fdbe@gateway/web/freenode/ip.157.49.253.190 QUIT :Ping timeout: 260 seconds:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :This function has an optimal run time ( O(n log n) ) as well.:tushaar!~tushaar@47.29.215.238 PRIVMSG #wcalgo4 :Which inturn uses which sort?:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :And also, we can use this function to sort a part of the array. sort(a+i, a+j) sorts the elements of the array from index i to j-1.:Sai!9d31fdbe@gateway/web/freenode/ip.157.49.253.190 JOIN #wcalgo4:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :To use such functions, include the header file algorithms.h (Ofcourse, if you have included bits/stdc++.h already, that would do) :Pratik!6a4f92de@gateway/web/freenode/ip.106.79.146.222 PART #wcalgo4:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :Similarly, for searching:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :find(a,a+n,key) - linear search for key in the range a[0] to a[n-1]:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :binary_search(a,a+n,key) - binary search for key in the range a[0] to a[n-1]. Note that the array should be sorted in this case:Ashwin_!2f1dc4dd@gateway/web/freenode/ip.47.29.196.221 PRIVMSG #wcalgo4 :cool:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :(You can change the indices as per your requirement. Note that) :vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :With the same parameters as the sort function, we also have lower_bound and upper_bound:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :*search function :vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :lower_bound - element greater than or equal to:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :upper_bound - element strictly greater than the key:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :Similarly we have other useful functions as well:Ashwin_!2f1dc4dd@gateway/web/freenode/ip.47.29.196.221 PRIVMSG #wcalgo4 :Are these functions or parameters "lower_bound and upper_bound"?:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :Functions:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :lower_bound(a, a+n, key) :Ashwin_!2f1dc4dd@gateway/web/freenode/ip.47.29.196.221 PRIVMSG #wcalgo4 :What do they return?:Ashwin_!2f1dc4dd@gateway/web/freenode/ip.47.29.196.221 PRIVMSG #wcalgo4 :Oh got it:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :Say a list has 1 2 3 4 5. And you pass the key as 2. lower_bound returns 2. upper_bound returns 3:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :min(a,b) - returns minimum of a and b. max(a,b) - returns maximum of a and b:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :Similarly for arrays, we have min_element(a,a+n) - returns minimum of all the elements in the range a[0] to a[n-1]:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :In the same way, max_element:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :reverse(a,a+n) reverses the array:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :swap(a,b) swaps the values of a and b:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :So those are some of the most basic functions which we ll need:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :You can use this reference to read more about them: http://www.cplusplus.com/reference/algorithm/:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :You conveniently change parameters so that it matches your requirement :) :vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :Any doubts so far? :tushaar!~tushaar@47.29.215.238 PRIVMSG #wcalgo4 :Hey, is it better to stick to #include<algorithm> or #include<bits/stdc++.h>?:tushaar!~tushaar@47.29.215.238 PRIVMSG #wcalgo4 :In competitive programming I mean.:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :The latter. It saves time in writing code or figuring out which header files we need :P For example, we might also need - stack.h, queue.h, limits.h etc. Its painful to think of what we need right?:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :It wont affect your run time. So use it without any worries :D :Ashwin_!2f1dc4dd@gateway/web/freenode/ip.47.29.196.221 PRIVMSG #wcalgo4 :Are all this components of STL?:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :Yes:Ashwin_!2f1dc4dd@gateway/web/freenode/ip.47.29.196.221 PRIVMSG #wcalgo4 :cool:vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :So i guess that's it for today. Next session, we ll be looking into STL containers and basic number theory required for competitive coding. :vilas_m!~vilasnitk@202.12.80.10 PRIVMSG #wcalgo4 :Make sure you finish the problems posted on the group as soon as possible. Ping us anytime for help! :) :Ashwin_!2f1dc4dd@gateway/web/freenode/ip.47.29.196.221 PRIVMSG #wcalgo4 :Great!:Sai!9d31fdbe@gateway/web/freenode/ip.157.49.253.190 PRIVMSG #wcalgo4 :Sure!:Rohan_!75d943fb@gateway/web/freenode/ip.117.217.67.251 PRIVMSG #wcalgo4 :Sure:tushaar!~tushaar@47.29.215.238 QUIT :Ping timeout: 248 seconds:Rohan_!75d943fb@gateway/web/freenode/ip.117.217.67.251 PART #wcalgo4:tushaar!~tushaar@47.29.215.238 JOIN #wcalgo4:vilas_m!~vilasnitk@202.12.80.10 PART #wcalgo4:shamitha!2f1ddede@gateway/web/freenode/ip.47.29.222.222 PART #wcalgo4:Sai!9d31fdbe@gateway/web/freenode/ip.157.49.253.190 QUIT :Quit: Page closed:tushaar!~tushaar@47.29.215.238 QUIT :Quit: Lost terminal