AliArapov221's blog

By AliArapov221, history, 7 months ago, In English

Does anybody know how to get variables in TopCoder and return answer using c++? Like in almost in every other judge i use std::cin but in TopCoder it gives you variables like in function. Can anybody send example code?

Thanks to nilucf19 for giving me link to tutorial! Let's consider next example:

Class:	XMarksTheSpot
Method:	countArea
Parameters:	String[]
Returns:	int

So to get variables you should make class with name after "Class: ", within you have to write public function with type written after "Returns: " named after "Method: ", with parameters listed after "Parameters: "

So in this case it should look like this:

class XMarksTheSpot{
public:
    int countArea(vector <string> s){
        
    }
};

Outside class you can write your own templates, defines, global variables, etc. To run your own testcase, you can use Test Panel in web arena and Test Button on applet arena.

More in : https://www.topcoder.com/thrive/articles/competitive-programming-at-topcoder-a-step-by-step-guide

And: https://www.topcoder.com/community/competitive-programming/how-to-compete

Also there's little generator in which you just input first four lines after "Definition" and it creates class named after it:

https://pastebin.com/gSHe6SFU

Sorry for my bad english.

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it