Tameshk's blog

By Tameshk, 6 years ago, In English

I want to invite you to share your template code which you're using for Codeforces contests using Carbon(free and open-sourse) project. Mine (First but not Best!):

Hope you guys take care in this time of corona-related hardship!

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

| Write comment?
»
6 years ago, hide # |
 
Vote: I like it +10 Vote: I do not like it

here is an ugly looking Template. ;)

»
6 years ago, hide # |
 
Vote: I like it +15 Vote: I do not like it

Not a macro guy so mine's prob shorter than most. The stuff at the top is just debugging template.

»
6 years ago, hide # |
 
Vote: I like it +6 Vote: I do not like it

Thankx for letting us know about Carbon. It's AMAZING ;)

»
6 years ago, hide # |
 
Vote: I like it +87 Vote: I do not like it

Unsurprisingly, the length of the template has (from the examples so far) been inversely correlated with CF rating :^)

»
6 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

[Here is a simple one.](carbon-1)

»
6 years ago, hide # |
 
Vote: I like it +6 Vote: I do not like it

Here's mine :) Different sections are imported when needed (not by default).

P.S. Your project is really awesome ^_^

»
6 years ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

Here's the JAVA code template I use:

carbon74c05b1e0890611d.png)

»
6 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Well just those common macros nothing fancy(as expected from a noob xD (carbon70d89b563183424e.png)

  • »
    »
    6 years ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    was curious about how you wrote cubefreak777 ?? like is there a script or something or you did it manually?

»
6 years ago, hide # |
Rev. 3  
Vote: I like it +55 Vote: I do not like it

I don't have a proper template :) Probably, because I'm too lazy. For people with big templates: please, consider hiding them in spoilers, it would make the thread much more readable.

»
6 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

 Can someone tell me how to use that clock to check execution time,its not working.

  • »
    »
    6 years ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Maybe you're not compiling with the correct preprocessor directive? Your code snippet seems to require LOCAL_RELEASE to be defined.

»
6 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

»
6 years ago, hide # |
Rev. 2  
Vote: I like it +3 Vote: I do not like it
Spoiler
  • »
    »
    6 years ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    You can call both power1 and power2 power; the difference in header will overload the function signature and the version called will just depend on whether you pass in the mod argument. Also, it probably won't matter because ll overflow is rare, but you may want to rewrite the lcm argument as (x/gcd(x,y))*y to prevent x*y from overflowing.

»
6 years ago, hide # |
 
Vote: I like it +4 Vote: I do not like it

here is mine, it's so simple btw carbon looks very nice, great work Tameshk

Spoiler
»
6 years ago, hide # |
 
Vote: I like it +11 Vote: I do not like it
Spoiler
»
6 years ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

  • »
    »
    6 years ago, hide # ^ |
    Rev. 2  
    Vote: I like it +27 Vote: I do not like it

    Hi. I see you are using c++17 on cf. I'd like to tell you about one funny thing. Your template has lcm function which is defined for long longs, but c++17 has it's own function with the same name, so it replaces yours with the std one. Why does it matter? Std function's return type is the same as argument type, so if you run

    cout << lcm(1000000000, 1000000000 - 1);
    

    You will see 1808348672( overflow ), because args are of type int. It's very tricky, isn't it? Here's how you can fix it:

    1. add #define lcm(x, y) lcm((ll)(x), (ll)(y)) instead of implementing your own lcm function

    2. add #define lcm randomlongstringwhichyouwillneveruseasanameorsomethinglikethat after including libraries, this way your function will be used

    p. s. talking about lcm I suggest that shahil_005 throws that weird-ass lcm function out of his template there are so many things wrong with it

    UPD: soumitri2001 you have fucked up lcm function as well(but for a different reason. Change (long) (a*b/gcd(a,b)) to (long) ((long)a*b/gcd(a,b)). The a*b part gives you overflow

»
6 years ago, hide # |
Rev. 7  
Vote: I like it +49 Vote: I do not like it

I don't know how to use macro

»
6 years ago, hide # |
 
Vote: I like it +92 Vote: I do not like it

Here's mine:

carbon-1

Usually, I start from scratch, or copy-paste from my last code
I don't have any macros

»
6 years ago, hide # |
 
Vote: I like it +18 Vote: I do not like it

Whats the point in posting screenshots of sourcecode?

»
6 years ago, hide # |
Rev. 3  
Vote: I like it 0 Vote: I do not like it

1000 lines of code just make it stucked... UPD:Just like this code

»
6 years ago, hide # |
 
Vote: I like it +11 Vote: I do not like it

»
6 years ago, hide # |
Rev. 3  
Vote: I like it 0 Vote: I do not like it

This is mine, I saw Geothermal use it in his Div. 3 unofficial editorial and thought it was good and that I wouldn't have to change it for a long period of time, and so far it's served me really well. Though I made a few edits of my own.  Pastebin link because I just can't get carbon to upload the template

»
6 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Here's mine template, ugly but fun. ;D

»
6 years ago, hide # |
 
Vote: I like it +1 Vote: I do not like it
My query template
My graph template
My Hello-World template
My normal template
»
6 years ago, hide # |
 
Vote: I like it +13 Vote: I do not like it

You can avoid to use macro CONFIG:

const bool ready = [](){
    std::ios_base::sync_with_stdio(false); std::cin.tie(0);
    std::cout << std::fixed << std::setprecision(12);
    return true;
}();

This lambda will be called before main. Example

»
6 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

My template

»
6 years ago, hide # |
Rev. 2  
Vote: I like it +3 Vote: I do not like it

C++:

Rust:

»
6 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Ok so I was preparing to post but I really didn't want to drown everybody's codes with my monster, gotta share the spotlight. See any of my submissions 78664902 to understand :p

»
6 years ago, hide # |
 
Vote: I like it +35 Vote: I do not like it

Creating images instead of pasting code with CF formatting. Heavier page to load, and nobody can't copy-paste something useful from here, nice.

»
6 years ago, hide # |
 
Vote: I like it +6 Vote: I do not like it

Short, efficient, unique.

I use snippet shortcuts to insert algorithms and implementations when needed.

»
6 years ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

I don't use it during contests, because I don't have time to complete it yet, but I published mine on my blog : Input/Output.

I also have a tool that includes functions that I need at compile-time on my github : C-Tool

»
6 years ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

Here's my submission template :)

»
6 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Short and simple, loaded and ready for multiple test-cases and focus only on the solve function.

»
6 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Too much templates !!! I will have long long time to learn all of this. Thank you everyone <3

»
6 years ago, hide # |
Rev. 2  
Vote: I like it +1 Vote: I do not like it

My UltiSnips snippet for vim

»
6 years ago, hide # |
 
Vote: I like it -19 Vote: I do not like it

It failed to accommodate the whole code, so a huge part of this picture is just black.

»
6 years ago, hide # |
 
Vote: I like it +2 Vote: I do not like it

Why does every body using dark theme? :) carbon.png

»
6 years ago, hide # |
 
Vote: I like it +18 Vote: I do not like it

it's mine :)

»
6 years ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

I want this theme for my compiler...anyone knows either online or offline compiler which contain this theme .

»
6 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

»
6 years ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

  • »
    »
    6 years ago, hide # ^ |
    Rev. 2  
    Vote: I like it 0 Vote: I do not like it
    My ugly template
»
6 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

My template is

here

Standard I think. Not using

Header

I feel like it is too slow when running on test cases...

»
6 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Here you g----->o
carbon-1

»
6 years ago, hide # |
Rev. 3  
Vote: I like it 0 Vote: I do not like it

»
6 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it
Template

Small and simple

»
6 years ago, hide # |
 
Vote: I like it +8 Vote: I do not like it

The main thing is #define int long long. WA from overflow too many times

»
6 years ago, hide # |
 
Vote: I like it +5 Vote: I do not like it
Template

Debugger that you might like, since it can be used without writing a single line of code in your final submission file.
(See sample_program in the link given above.)

»
6 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I try to keep it as simple as possible, and not exaggerated.

»
6 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

carbon.png