When submitting a solution in C++, please select either C++14 (GCC 6-32) or C++17 (GCC 7-32) as your compiler. ×

Tyr's blog

By Tyr, 11 years ago, In English

Hi !

Can any of java coders provide me a good template for submitting solutions in different online judges ? I always have trouble with StringTokenizer and so on..., maybe you say so forget java ! and code in C++ but I say java is Cool and java coders are different so I want to be different to (despite the fact that language is nothing but a tool and algorithm and problem solving is important as we see in Knuth TAOCP that he uses Assembly !)

Full text and comments »

  • Vote: I like it
  • -8
  • Vote: I do not like it

By Tyr, 11 years ago, In English

Hi, I want to generate bit strings of length n and exactly m ones I came up with this algorithm but can't make it more efficient any Idea ? or am I doing optimization right ?


// cin >> number >> no; // sample input 3 1 // smaple output: // 0 0 1 // 0 1 0 // 1 0 0 int number, nOnes, no; int solution[10000]; void backtrack(int n) { if(n == number) { if(nOnes == no) print(); } else { int candidates[] = {0, 1}; for(int i = 0; i < 2; i++) { if(candidates[i] == 1) { nOnes += 1; if(nOnes > no){ nOnes--; return; } } solution[n] = candidates[i]; backtrack(n + 1); if(candidates[i]) nOnes -= 1; } } }

Full text and comments »

  • Vote: I like it
  • +5
  • Vote: I do not like it

By Tyr, 11 years ago, In English

Hi

Yesterday I just found this site "jutge.org" and I thought that it's great site for newbies (like me)

my question is , have (has?) anybody participated in this site and solved problems and how he/she evaluates the material of this site ? Does it worth spending a summer solving tasks listed in "Algorithm" course by this website ? Please leave a comment if you have something to say :)

Full text and comments »

  • Vote: I like it
  • -16
  • Vote: I do not like it