e3e's blog

By e3e, history, 5 weeks ago, In English

I see some very good coders such as snuke, Petr do this. struct Solver and writing their actual solution in the Solver's method void solve(). Is there any practical benefit of doing this?

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

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

They probably get used to code in Java, hence they use OOP/struct in C++.

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Don't know about them but i personally use this so that in multiple tc's questions i can write

This

Instead of

This
  • »
    »
    5 weeks ago, # ^ |
    Rev. 2   Vote: I like it +3 Vote: I do not like it

    really convenient, no need to if -> break for all like 3 looped loops, just return -> ez gg

»
5 weeks ago, # |
  Vote: I like it +11 Vote: I do not like it

Ability to reset global variables at tasks with multitests

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    can't I just reset global variables just with void solve()? why need struct Solver?

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

One advantage is that order of function defintions doesn't matter. You can use a function defined below your main function inside main function.

Code Example