Template for CP competitions such as ICPC, CodeForces, etc. Written in C++.
A C++ template for competitions such as ICPC, CodeForces, AtCoder, etc.
The main goal of this template is to be very powerful and convenient.
The IDE where cp-programming-template is developing - Microsoft Visual Studio 2022 Community Edition.
Just copy & paste content of "likespro.eth - UNIVERSAL/likespro.eth - UNIVERSAL.cpp" to your empty program. Or simply download repo and start coding in this project.
Variables names in brackets () can be replaced to any other names, for example: vi a; sort(all(a)) - here n in all(n) was replaced to the name of existing vector<int>
iostreamvectoralgorithmcmathsetmapnumericqueuecassertstringsstreambitsetnumericiomanipunordered_maprandom
std
-
int=long long -
uint=unsigned int -
sz=size() -
pb=push_back -
mp=make_pair -
all(n)=(n).begin(), (n).end() -
rall(n)=(n).rbegin(), (n).rend() -
elif=else if -
flag=bool f = 0; -
SVap=swap(the most Essential Define from YuriyKap) -
forin=for(int i = 0; i < n; i++) -
rofin=for(int i = n; i >= 0; i--) -
fori(n)=for(int i = 0; i < (n); i++) -
rofi(n)=for(int i = (n); i >= 0; i--)
iont=intitn=intfor9int=for(intsvap=SVapbreakl=breakcontinuel=continuevoif=void
INF=2000000000MOD=1000000007MOD_EOLYMP=998244353PI=3.14159265359ALPHABET=abcdefghijklmnopqrstuvwxyzYES=YESNO=NOBUF_SZ=1000000INT_MAX=2147483647INT_MIN=-2147483648
Trip- Structure with three elements -first,secondandthird
vi=vector<int>vvi=vector<vi>vb=vector<bool>vvb=vector<vb>pii=pair<int, int>pdi=pair<double, int>pipii=pair<int, pii>tiii=Trip<int, int, int>vpii=vector<pii>vpdi=vector<pdi>vpipii=vector<pipii>vvpii=vector<vpii>vtiii=vector<tiii>vc=vector<char>vvc=vector<vc>vstr=vector<string>si=set<int>spii=set<pii>vsi=vector<si>msi=multiset<int>mspii=multiset<pii>mii=map<int, int>mapsi=map<string, int>mib=map<int, bool>mipii=map<int, pii>mitiii=map<int, tiii>mpiivpii=map<pii, vpii>misi=map<int, si>mivi=map<int, vi>qi=queue<int>vqi=vector<qi>
via=vi avib=vi bvian=vi a(n)viam=vi a(m)vibn=vi b(n)vibm=vi b(m)
retyes- prints "YES" and returns from function where it was calledretno- prints "NO" and returns from function where it was called
xin()- reads newlong longnumber fromstdinusingcinand returns this numberTemporary disabled becausefileio(filename, [input_file_suffix], [output_file_suffix])- binds<filename><input_file_suffix>tostdinand<filename><input_file_suffix>tostdout. Default value forinput_file_suffixis.in, foroutput_file_suffix-.out.Microsoft Visual Studio 2022does not support ittros(begin_iterator, end_iterator)- sort array in order from the biggest to the lowest
>>vector-istreamforvector, reads to all elements. Example of usage:cin>>vector;<<vector-ostreamforvector, prints all elements separated by space. Example of usage:cout<<vector;
CompilerTests- simple functions to test if compiler is working properly. Contains:helloWorld()- printHello, world!sum()- read 2 numbers and output their sum
srand(time(NULL))- initializes default random using current time as seedios::sync_with_stdio(false)- disables sync with stdio for higher performance ofcinandcoutcin.tie(0); cout.tie(0)- optimizations forcinandcoutbool multiTestEnabled = false- if set totrue, the program will read number of subtests and run those times the specified function with solution for subtestwhile (t--) <function with solution>- here you need to specify the function with solution
This is because the file where likespro code all solutions is called so; template is extracted from the file with solutions.
Raw file with no extracted solutions is in "tasks-solutions" branch. But I really wonder why do you need it...
