diff --git a/Implementations/content/contest/CppIO.h b/Implementations/content/contest/CppIO.h index 60756aef..6b4271f1 100644 --- a/Implementations/content/contest/CppIO.h +++ b/Implementations/content/contest/CppIO.h @@ -143,12 +143,17 @@ inline namespace Output { #define dbg(...) loc_info(__LINE__,#__VA_ARGS__), dbg_out(__VA_ARGS__) #define dbgl(lev,x) loc_info(__LINE__,#x), dbgl_out(x) #else // don't actually submit with this - #define dbg(...) 0 - #define dbgl(lev,x) 0 + #define dbg(...) + #define dbgl(lev,x) #endif - const clock_t beg = clock(); - #define dbg_time() dbg((db)(clock()-beg)/CLOCKS_PER_SEC) + // https://stackoverflow.com/questions/47980498/accurate-c-c-clock-on-a-multi-core-processor-with-auto-overclock?noredirect=1&lq=1 + const auto beg = std::chrono::high_resolution_clock::now(); + void dbg_time() { + auto duration = chrono::duration( + std::chrono::high_resolution_clock::now() - beg); + dbg(duration.count()); + } } inline namespace FileIO { diff --git a/Implementations/content/contest/Snippets.md b/Implementations/content/contest/Snippets.md index decc0c73..260db9df 100644 --- a/Implementations/content/contest/Snippets.md +++ b/Implementations/content/contest/Snippets.md @@ -25,7 +25,7 @@ struct ${1:Name} { #ifdef LOCAL int main() { ${1:Name} c; ps(c.${2:method}()); - dbg((db)(clock()-beg)/CLOCKS_PER_SEC); + dbg_time(); } #endif ``` diff --git a/Implementations/content/contest/TemplateLong.cpp b/Implementations/content/contest/TemplateLong.cpp index f1dcc6f8..8458b3a2 100644 --- a/Implementations/content/contest/TemplateLong.cpp +++ b/Implementations/content/contest/TemplateLong.cpp @@ -249,12 +249,17 @@ inline namespace Output { #define dbg(...) loc_info(__LINE__,#__VA_ARGS__), dbg_out(__VA_ARGS__) #define dbgl(lev,x) loc_info(__LINE__,#x), dbgl_out(x) #else // don't actually submit with this - #define dbg(...) 0 - #define dbgl(lev,x) 0 + #define dbg(...) + #define dbgl(lev,x) #endif - const clock_t beg = clock(); - #define dbg_time() dbg((db)(clock()-beg)/CLOCKS_PER_SEC) + // https://stackoverflow.com/questions/47980498/accurate-c-c-clock-on-a-multi-core-processor-with-auto-overclock?noredirect=1&lq=1 + const auto beg = std::chrono::high_resolution_clock::now(); + void dbg_time() { + auto duration = chrono::duration( + std::chrono::high_resolution_clock::now() - beg); + dbg(duration.count()); + } } inline namespace FileIO { diff --git a/Implementations/content/geometry (13)/chapter.tex b/Implementations/content/geometry (13)/chapter.tex index b9461e1e..dd02c1ae 100755 --- a/Implementations/content/geometry (13)/chapter.tex +++ b/Implementations/content/geometry (13)/chapter.tex @@ -30,7 +30,7 @@ \section{Circles} \section{Misc} \kactlimport{Misc/ClosestPair (13.2).h} % \kactlimport{Misc/KDtree.h} - \kactlimport{Misc/DelaunayIncremental.h} + % \kactlimport{Misc/DelaunayIncremental.h} \kactlimport{Misc/DelaunayFast.h} \kactlimport{Misc/ManhattanMST.h} @@ -38,5 +38,5 @@ \section{3D} \kactlimport{3D/Point3D.h} \kactlimport{3D/Hull3D.h} \kactlimport{3D/PolySaVol.h} - \kactlimport{Misc/Delaunay3.h} + % \kactlimport{Misc/Delaunay3.h} \ No newline at end of file diff --git a/Implementations/content/number-theory (11.1)/Modular Arithmetic/ModFact.h b/Implementations/content/number-theory (11.1)/Modular Arithmetic/ModFact.h index 603e6e60..71425413 100644 --- a/Implementations/content/number-theory (11.1)/Modular Arithmetic/ModFact.h +++ b/Implementations/content/number-theory (11.1)/Modular Arithmetic/ModFact.h @@ -3,12 +3,12 @@ * Time: O(N) * Source: KACTL * Verification: https://dmoj.ca/problem/tle17c4p5 - * Usage: Factorials F; F.init(10); F.C(6, 4); // 15 + * Usage: F.init(10); F.C(6, 4); // 15 */ #include "ModInt.h" -struct Factorials { +struct { vmi invs, fac, ifac; void init(int N) { // idempotent invs.rsz(N), fac.rsz(N), ifac.rsz(N); @@ -20,4 +20,4 @@ struct Factorials { if (a < b || b < 0) return 0; return fac[a]*ifac[b]*ifac[a-b]; } -}; \ No newline at end of file +} F; \ No newline at end of file diff --git a/README.md b/README.md index e96824d1..ead6c2d8 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,13 @@ # README -Some material has been moved to the [USACO Guide](https://usaco-guide.vercel.app/). +Some material has been moved to the [USACO Guide](https://usaco.guide/). ## Notes -I am currently not updating the following pages: +I am not planning to update: - * README's for most implementations - * tables and solutions for non-platinum USACO contests +- READMEs for most implementations +- USACO problem tables and solutions + - Tables for recent USACO problems can be found [here](https://usaco.guide/general/usaco-monthlies). -Since I frequently move stuff around, some text may refer to files which no longer exist. If you would like to contribute, provide feedback, or encourage me to update something, please email me at *bqi343@gmail.com* or submit a pull request. If you have a question, please read the entirety of "Resources" -> "Questions.md" first. +Since I frequently move stuff around, some READMEs may refer to files which no longer exist. If you would like to contribute, provide feedback, or encourage me to update something, please email me at *bqi343@gmail.com* or submit a pull request. If you have a question, please read the entirety of "Resources" -> "Questions.md" first. diff --git a/Resources/Questions.md b/Resources/Questions.md index 4b23ab5f..952f8f5c 100644 --- a/Resources/Questions.md +++ b/Resources/Questions.md @@ -2,6 +2,8 @@ You might want to read [Um_nik's FAQ](https://codeforces.com/blog/entry/47516) too. I hope this is slightly more informative. :) +(Update: FAQs specifically for USACO contests can be found [here](https://usaco.guide/general/usaco-faq).) + ## General > Hey, could you help me get started with competitive programming. @@ -16,7 +18,7 @@ You might want to read [Um_nik's FAQ](https://codeforces.com/blog/entry/47516) t > I have just started on codeforces and competetive programming. Can you suggest something? -I hope this link helps you. If not, please let me know! +I hope this document helps you. If not, please let me know! > does this contains all the things or full training materials @@ -38,25 +40,25 @@ Mostly just looking stuff up along the way. > What are the ways that you practice makes you so perfect about programming? -Keep doing interesting problems (and stay organized??) idk +idk -> I find difficult to prepare for math and cp competitions together without neglecting school ... I know you obviously can't solve my problem, but I'd just like to have the advice of an expert like you and if you've ever been in my situation +> I find difficult to prepare for math and cp competitions together without neglecting school ... I know you obviously can't solve my problem, but I'd just like to have the advice of an expert like you and if you've ever been in my situation -You shouldn't neglect school, but generally I've kept up with schoolwork and still had plenty of free time. +Generally I've kept up with schoolwork and still had plenty of free time. > do you have a particular method to organize time well and manage everything (competitions, courses, homework ...) > Pls which calendar do u use to structure ur coding schedule. -clist.by & workflowy & google calendar +[clist.by](https://clist.by/) & workflowy & google calendar. [Notion](https://www.notion.so/) is good too. > Which site to practice on ? I want to concentrate only on one ... Which is better way of practice, doing questions topic wise ? Or sorting all the questions in ascending order and try to complete as many as possible ? -I don’t know, try all of them and see what works for you ... +idk, try all of them and see what works for you ... > What was your strategy considering you were preparing for IOI. -Other than doing past IOI tasks, I didn't do anything specifically for IOI. If you're looking for olympiad problems see "Contests." +Other than doing past IOI tasks, I didn't do anything specifically for IOI. ## Redirection @@ -70,23 +72,23 @@ See "Competition Math." > which problems should I solve -See "Contests." +See [Contests](https://usaco.guide/general/contests). > Can you provide me some coding books where I can inprove my skills. -See "Resources." +See [Resources](https://usaco.guide/general/resources-cp). > I looked at your guide, but some resources were quite difficult. -See "Resources" again; I think that CPH and USACO Bronze are definitely okay for beginners. +See [Resources](https://usaco.guide/general/resources-cp) again; I think that CPH and USACO Bronze are definitely okay for beginners. -> i think whenever i am learning some new topic i m not able to solve good questions on that topic so thats what holding me back. +(Update: USACO Bronze is harder nowadays so maybe this is not actually true ... [here](https://usaco.guide/general/expected-knowledge) are some suggestions) -I hope the links in "Implementations" will suffice. +> i think whenever i am learning some new topic i m not able to solve good questions on that topic so thats what holding me back. > Can you suggest me some of the topics or algorithms I need to master to rock on Silver Category??? -See "Contests" -> "USACO Links." +See the [USACO Guide](https://usaco.guide/). ## Topics @@ -96,7 +98,7 @@ See "Contests" -> "USACO Links." Well, a fair amount of C and D questions are hard precisely because they don't really fall into any of these categories. -> i m always interested in this but i m not able to understand whether i m doin wrong by taking hard topics and not able to solve questions on them or am i doing wrong on solving too easy ones , +> i m always interested in this but i m not able to understand whether i m doin wrong by taking hard topics and not able to solve questions on them or am i doing wrong on solving too easy ones , Idk, there are plenty of hard questions involving easy topics. @@ -120,11 +122,11 @@ The former is quite good. I haven't read the latter. > i need help with a problem related to calculating ( a power b )mod prime -> i need help with a combinatorial problem. the problem is as follows : given a grid of size 2xN, you need to count number of ways to paint the blocks of this grid with M litres of red colour such that painted blocks does not share a side. To paint 1 block ,1 litre of colour is required. I can do this with the help of dynamic programming if value of N less than 1000. Can I solve this problem in case of N <= 10^9. (codechef) +> i need help with a combinatorial problem. the problem is as follows : given a grid of size 2xN, you need to count number of ways to paint the blocks of this grid with M litres of red colour such that painted blocks does not share a side. To paint 1 block ,1 litre of colour is required. I can do this with the help of dynamic programming if value of N less than 1000. Can I solve this problem in case of N <= 10^9. (codechef) > hi dude, can you help me please?, I realy stuck at this problem, could you give me a hint?, I think it is a graph problem -If you give me a link to the problem and I find it sufficiently interesting, then I might solve it (or not, if I don't check my messages). +If you give me a link to the problem and I find it sufficiently interesting, then I might solve it (or not). > Any opinion on working through random contests v.s. practicing topic by topic? @@ -152,13 +154,13 @@ Until recently, I don’t believe that I have ever finished a virtual contest wh > could you please tell me which IDE do you use on your MAC? -I use https://ideone.com/ LOL. I used to use https://csacademy.com/ but it looks like the queue times are rlly bad now. Locally I use Sublime Text w/ command line. At IOI I used Geany. - -[Why the downvotes? :(](https://codeforces.com/blog/entry/63065?#comment-469907) +I used to use https://ideone.com/ or https://csacademy.com/workspace/. Now I use Sublime Text w/ command line. At IOI I used Geany. > Do you use a debugger? -No, ~~I can't figure out how to get GDB to work on Mac~~ and print statements generally suffice. Actually, [these instructions](https://sourceware.org/gdb/wiki/BuildingOnDarwin) work but sometimes it hangs ... +No, ~~I can't figure out how to get GDB to work on Mac~~ and print statements generally suffice. + +(Update: I got LLDB working on Mac but I haven't actually used it in-contest.) > did you do it on your own or did you have a coach ! @@ -170,10 +172,9 @@ mostly self? haven't been tutored or done any tutoring myself ## Bad - > I've been doing Programming since almost 2 years, And I didn't see a much progress. I sometimes struggle with Div2 C in contest time. I have solved almost 400 problems from different OJs like spoj, codechef or cf. I generally got fear from higher difficulty problems. -> i left coding some months ago. i was distressed as i was not doing well as i was not improving , the time when i started codechef contests i was stuck on question 4 or 5 and now also i m stuck on same level questions +> i left coding some months ago. i was distressed as i was not doing well as i was not improving , the time when i started codechef contests i was stuck on question 4 or 5 and now also i m stuck on same level questions Do more problems? :shrug: @@ -207,7 +208,7 @@ Doubt it. (How are you going to do ALL of the questions that I've done? o_O) > How many hours you practice daily? -Idk, you can probably estimate from my submission history and tell me. +Idk. Maybe you can probably estimate from my submission history and tell me. > ur graph seems very interesting to me . @@ -215,13 +216,15 @@ ok ! > but i don't know where to start -idk either (just go with CPH?) +idk either + +(Update: [Here](https://usaco.guide/general/expected-knowledge) are some suggestions.) > please please could u please tell me how much mathematics or TOPICS needed for CP ? please tell me please a lot -> how can I solve problem B(div 2) and C(div 2) regular in codeforces contest +> how can I solve problem B(div 2) and C(div 2) regular in codeforces contest think (and practice) @@ -229,7 +232,7 @@ think (and practice) yes -> If I walk with your link on github only enough to be a master on CodeForces in 3 month's , and Pass an interview in international companies like : amazon , facebook , apple , google...etc +> If I walk with your link on github only enough to be a master on CodeForces in 3 month's , and Pass an interview in international companies like : amazon , facebook , apple , google...etc no