diff --git a/lua/custom/init.lua b/lua/custom/init.lua index a6b9e170..d68134b1 100644 --- a/lua/custom/init.lua +++ b/lua/custom/init.lua @@ -3,6 +3,7 @@ -- require("custom.plugins") -- Custom plugins require 'custom.snippets.edhliicpp' -- Custom snippets require 'custom.snippets.edhliic' -- Custom snippets +require 'custom.snippets.testgen' -- Set some editor options vim.opt.number = true diff --git a/lua/custom/snippets/edhliicpp.lua b/lua/custom/snippets/edhliicpp.lua index d423be38..11c2f29a 100644 --- a/lua/custom/snippets/edhliicpp.lua +++ b/lua/custom/snippets/edhliicpp.lua @@ -13,8 +13,8 @@ ls.add_snippets('cpp', { 'using namespace std;', 'typedef long long ll;', 'typedef unsigned long long ull;', - 'const int N = 1E6 + 3;', - 'const ll MOD = 1E9 + 7;', + 'const int N = 1000006;', + 'const ll MOD = 1000000007;', '', 'int main() {', ' ios_base::sync_with_stdio(false);', diff --git a/lua/custom/snippets/testgen.lua b/lua/custom/snippets/testgen.lua new file mode 100644 index 00000000..cc81e97b --- /dev/null +++ b/lua/custom/snippets/testgen.lua @@ -0,0 +1,48 @@ +local ls = require 'luasnip' +local s = ls.snippet +local t = ls.text_node + +ls.add_snippets('cpp', { + s('testgen', { + t { + '#include ', + '#define NAME "BAI1"', + 'using namespace std;', + 'typedef long long ll;', + 'typedef unsigned long long ull;', + 'const int N = 1000006;', + 'const ll MOD = 1000000007;', + '', + 'const int NTEST = 100;', + 'mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());', + '', + 'long long Rand(long long l, long long h) {', + ' unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();', + ' mt19937 gen(seed);', + ' uniform_int_distribution dis(l, h);', + ' long long x = dis(gen);', + ' return x;', + '}', + '', + 'void MakeTest() {', + ' ofstream cout(NAME ".INP");', + ' cout << "test";', + '}', + '', + 'int main() {', + ' srand(time(0));', + ' for (int iTest = 1; iTest <= NTEST; iTest++) {', + ' MakeTest();', + ' system("./" NAME "_trau");', + ' system("./" NAME);', + ' if (system("diff " NAME ".OUT " NAME ".ANS") != 0) {', + ' cout << "Test " << iTest << ": WRONG!\\n";', + ' return 0;', + ' }', + ' cout << "Test " << iTest << ": CORRECT!\\n";', + ' }', + ' return 0;', + '}', + }, + }), +})