代码混淆器,让你放心小号逃罚时
在打 CF 时,你有没有过拿小号交代码过了再用大号交以逃避罚时的想法?
又有没有过实践了上述想法导致 skip 一场比赛的经历?
如果有,那么你需要这款代码混淆器!
基于【项目】代码混淆器 by _sunkuangzheng_ 二次开发。
【功能介绍】
代码混淆器可以将你的变量名全部改成常见或随机字符串,同时添加一些随机注释,并保证代码还能正常运行。通过它,CF 将不能识别你的大小号代码是否雷同!
【使用说明】
测试环境为 Windows10, MinGW-GCC13。
请自行编译使用。
【已知 BUG】
目前对字符串的处理有问题,会将你输出的字符串替换为随机字符,预计
0.2 版本修复。 (已修复)
【版本号】
0.2
【源代码】
请自行编译使用:
#include <bits/stdc++.h>
using namespace std;
namespace Code_Maker{
vector<string> Key_Word{"auto","bool","char","int","short","long","float","double",
"signed","unsigned","false","true","enum","struct","class","namespace","std","using",
"cin","for","while","main","const","map","set","vector","pair","queue","stack",
"priority","do","if","else","inline","register","void","operator","break","continue","return",
"scanf","printf","floor","ceil","size","top","front","pop","bitset","cin","cout","push","back",
"clear","endl","string","swap","define","min","max","rand","sort","ios","sync","with","stdio","tie",
"sqrt","make","emplace","gcd","isdigit","getchar","first","second","memset","sizeof","begin","end",
"lower_bound","upper_bound","bound","unique","abs","lcm","__gcd","and","or","xor"};
vector<string> Bianliang_Name{"answer","result","lengthh","sizee","father","depth","value","valve","csgo","cs2","counter_strike2",
"nic","tuoc","ftnirp","kcuf","deg","LycoReco","NishikigiChisato","InoueTakina","omen","luogu","kkksb03","shen_bhe","BianLiang",
"Waccepted","AcrongAnswer","baoling","IAKIOI","jc","spfa","tarjan","SPFA","dfs1","dfs2","dfs3","dfs4","dfs5","dfs6","dfs114514",
"bfs1","bfs2","bfs3","bfs1919810","read","write","calc","solve","work","vscode","vim","dev_c__","dinic","This_Is_A_Value",
"This_Is_Also_A_Value","IDontKnow"};
vector<string> Zhushi_Name{"using dfs to get the Ans","I Love Coding","I want to AK IOI",
"I Don't Want to AK IOI","I Love Money","Codeforces is my favourite OJ","ATCoder is my favourite OJ",
"Luogu is my favourite OJ","Hydro is my favourite OJ"};
mt19937 rd(time(nullptr));
ifstream fin;
ofstream fout;
map <string,string> mymap;
int bianliang_cnt , zhushi_cnt;
bool is_val(char c , bool flag)
{
return ('a' <= c and 'z' >= c) or ('A' <= c and 'Z' >= c) or (flag and '0' <= c and '9' >= c);
}
string get_next_word(string s , int &pos)
{
string re = ""; int len = s.length() , now;
for (now = pos; now < len;) {
if (!is_val(s[now] , now>pos)){break;}
re += s[now]; now++;
}
if (now == pos){re += s[now++];}
pos = now;
return re;
}
string rd_name()
{
int len = rd() % 15 + 1;
string s = "";
for (int i = 0; i < len; i++){s += char(rd()%26+'a');}
return s;
}
string rd_zhushi()
{
int len = rd() % 15 + 15;
string s = "";
for (int i = 0; i < len; i++){s += char(rd()%26+'a');}
return s;
}
string new_bianliang()
{
if (++bianliang_cnt < Bianliang_Name.size()){return Bianliang_Name[bianliang_cnt];}
else{return rd_name();}
}
string new_zhushi()
{
if (++zhushi_cnt < Zhushi_Name.size()){return Zhushi_Name[zhushi_cnt];}
else{return rd_zhushi();}
}
void try_output_zhushi()
{
if (rd() % 20 == 0) {
fout << "/\/" << new_zhushi() << '\n';
}
}
void main()
{
shuffle(Bianliang_Name.begin() , Bianliang_Name.end() , rd);
shuffle(Zhushi_Name.begin() , Zhushi_Name.end() , rd);
for (auto i : Key_Word){mymap[i] = i;}
string in_file_name;
cout << "Pls Enter the File Name of Your Code: ";
cin >> in_file_name;
cout << "In Processing. Pls Wait...\n";
fin.open(in_file_name); fout.open("Code.cpp");
string s;
while(getline(fin , s)) {
int cnt = 0;
while(!s.empty() and s[0] == ' '){s.erase(0,1); cnt++;}
if (s.empty()){continue;}
int len = s.length();
if (s[0] == '#') {
int i = 1;
if (get_next_word(s , i) != "define") {
fout << s;
} else {
string ans = "#define";
while(i < len) {
if (!is_val(s[i] , 0)){ans += s[i++];}
else {
string tmp = get_next_word(s , i);
if (!mymap.count(tmp)){mymap.insert({tmp , new_bianliang()});}
ans += mymap[tmp];
}
} fout << ans;
}
} else {
while(cnt--){fout << ' ';}
int i = 0;
string ans = "";
while(i < len) {
if (!is_val(s[i] , 0)) {
if ('0' <= s[i] and '9' >= s[i]) {
while(i < len and is_val(s[i] , 1)) {
ans += s[i++];
}
} else if (s[i] == '\"') {
ans += s[i++];
while(i < len and s[i] != '\"') {
ans += s[i++];
}
if (i < len){ans += s[i++];}
} else {
ans += s[i++];
}
} else {
string tmp = get_next_word(s , i);
if (!mymap.count(tmp)){mymap.insert({tmp , new_bianliang()});}
ans += mymap[tmp];
}
} fout << ans;
}
try_output_zhushi();
fout << '\n';
try_output_zhushi();
}
}
}int main(){Code_Maker :: main(); return 0;}