e3e's blog

By e3e, history, 3 months 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

»
3 months 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++.

»
3 months 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
  • »
    »
    3 months 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

»
3 months ago, # |
  Vote: I like it +11 Vote: I do not like it

Ability to reset global variables at tasks with multitests

  • »
    »
    3 months 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?

»
3 months 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