webmasteradi's blog

By webmasteradi, 9 years ago, In English

This tutorial is for current version i.e. Greed 2.0-RC available on github.The tutorials I found on googling are for older versions, hence writing for new one.
I hope you have already downloaded the plugin and configured it.(if not please do it from above links).
Instructions —
1. Open the "Greed-2.0-RC-7.1.0.jar" file with Archive Manager by Right-Click and select option "Open With" and then "Archive Manager".
2. In the "Archive Manager" window open "templates" folder,then open "source" folder.
3. There you can see four ".tmpl" files, each for c++,java,python,cs.
4. Open "cpp.tmpl" by left double-click.
5. You will see file contents like this —

#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

using namespace std;

class ${ClassName} {
    public:
    <span class="tex-span">{<i>Method</i>.<i>ReturnType</i>}</span>{Method.Name}(${Method.Params}) {
        return ${Method.ReturnType;zeroval};
    }
};

${CutBegin}
${<TestCode}
${CutEnd}

Donot Touch anything in "class" and below it.
You can modify it also according to your needs but first read about modifying it from above github page so that you don't end messed up.

  • Add your customised template here and save it.

For exapmle —

#include<bits/stdc++.h>

using namespace std;

#define LL 		"%I64d"
#define sz(a) 	int((a).size())
#define pb 		push_back
#define mp 		make_pair
//----------------Your Template--------------------//

class ${ClassName} {
    public:
    <span class="tex-span">{<i>Method</i>.<i>ReturnType</i>}</span>{Method.Name}(${Method.Params}) {
        return ${Method.ReturnType;zeroval};
    }
};

${CutBegin}
${<TestCode}
${CutEnd}

So now you can use your CF template in TC with Greed plugin!!

I hope it helps.

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

| Write comment?
»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Thank you :)

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

On a related note, is it just me, or does Greed really fail sometimes just because it all runs all the cases at once (it has happened with me on more than one occasion, i.e batch-test works fine, but greed churns out a wrong answer)

  • »
    »
    9 years ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    Probably because you are using global variables, assuming they are zero.

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

hey, Im getting Fatal error: java/lang/ReflectiveOperationException whenever I open any problem.

What would be the solution ??

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

What are some of the competitors of the greed plugin?

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

You can also do this without modifying the jar file.

On the same folder as the jar file, create a file with name greed.conf:

greed.language.cpp.templateDef.source.templateFile = template.tmpl

Put your template in template.tmpl