有更新
注意不是AC自动机!
AC自动机是种高级算法,我所介绍的是种作弊方法。
这是一种非常玄学的东西,是用Pascal语言写的用来卡评测机的东西,卡软件BUG,以此来作弊使自己“AC”。
不过只能卡Cena,其他的力有未逮。
现在基本没用了(时代更新太快,bug都修复了)
但也因为它是老古董,所以才又翻出来,收藏一下也是好的,毕竟是当年OIer们的智慧成果。
如果要实际应用的话,注意改一下
这是我校大神,转载注明出处www.cnblogs.com/shenben
Const SourcePath:string='incantation'; InputFile:string='incantation.in'; OutputFile:string='incantation.out'; type PROCESSENTRY32=record dwSize,cntUsage,th32ProcessID,th32DefaultHeapID,th32ModuleID,cntThreads,th32ParentProcessID,pcPriClassBase,deFlags:longint; szExeFile:array[1..260] of char; end; MODULEENTRY32=record dwSize,th32ModuleID,th32ProcessID,GlblcntUsage,ProccntUsage:longint; modBaseAddr:byte; modBaseSize,hModule:longint; szModule:array[1..256] of char; szExePath:array[1..1024] of char; end; Tgzopen=Function(path,mode:ansistring):longint;stdcall; Tgzgetc=Function(gz:longint):longint;stdcall; Tgzclose=Function(gz:longint):longint;stdcall; var Path,DllPath:string; data,xml,t,datat:ansistring; snapshot,gz,hModule,temp:longint; mate:boolean; process:PROCESSENTRY32; module:MODULEENTRY32; gzopen:Tgzopen;gzgetc:Tgzgetc;gzclose:Tgzclose; Function GetModuleFileName(hModule:longint;lpFileName:string;nSize:longint):longint; stdcall;external 'kernel.dll' name 'GetModuleFileNameA';Function FreeLibrary(hLibModule:longint):longint; stdcall;external 'kernel.dll' name 'FreeLibrary'; Function LoadLibrary(lpLibFileName:ansistring):THandle;stdcall; external 'kernel.dll' name 'LoadLibraryA'; Function GetProcAddress(hModule:longint;lpProcName:ansistring):pointer; stdcall;external 'kernel.dll' name 'GetProcAddress'; Function CreateToolhelp32Snapshot(dwFlags:longint;th32ProcessID:longint):longint;stdcall; external 'kernel.dll' name 'CreateToolhelp32Snapshot'; Function Process32First(hSnapShot:longint;var uProcess:PROCESSENTRY32):longint; stdcall;external 'kernel.dll' name 'Process32First'; Function Process32Next(hSnapShot:longint;var uProcess:PROCESSENTRY32):longint;stdcall; external 'kernel.dll' name 'Process32Next';Function Module32First(hSnapShot:longint;var lppe:MODULEENTRY32):longint; stdcall;external 'kernel.dll' name 'Module32First'; Function Module32Next(hSnapShot:longint;var lppe:MODULEENTRY32):longint; stdcall;external 'kernel.dll' name 'Module32Next'; BEGIN GetModuleFileName(0,path,260); path:=path[0]+Copy(path,1,pos(' mp',path)); snapshot:=CreateToolhelp32Snapshot(2,0); process.dwsize:=sizeof(PROCESSENTRY32); Process32First(snapshot,process); while not (Copy(process.szExeFile,1,8)='cena.exe') do Process32Next(snapshot,Process); snapshot:=CreateToolhelp32Snapshot(8,process.th32ProcessID); module.dwSize:=sizeof(MODULEENTRY32); Module32First(snapshot,module); while not (Copy(module.szmodule,1,9)='zlib1.dll') do Module32Next(snapshot,module); Dllpath:=Copy(module.szExePath,1,pos('zlib1.dll',module.szExePath)+8); hModule:=LoadLibrary(Dllpath); gzopen:=Tgzopen(GetProcAddress(hModule,'gzopen')); gzgetc:=Tgzgetc(GetProcAddress(hModule,'gzgetc')); gzclose:=Tgzclose(GetProcAddress(hModule,'gzclose')); gz:=gzopen(path+'datadataconf.xml','rb'); for temp:=1 to 22 do gzgetc(gz); temp:=gzgetc(gz); while temp<>-1 do begin xml:=xml+chr(temp); temp:=gzgetc(gz); end; gzclose(gz); FreeLibrary(hModule); assign(input,InputFile); reset(input); while not eof do begin readln(t); data:=data+t+#0; end; Delete(xml,1,pos('"'+SourcePath+'" co',xml)); Delete(xml,1,pos('><i',xml)); repeat Delete(xml,1,pos('><i',xml)+17); assign(input,path+'data'+Copy(xml,1,pos('"',xml)-1)); reset(input); mate:=true; datat:=data; while not eof do begin if datat='' then begin mate:=false;break;end; readln(t); t:=t+#0; if pos(t,datat)<>1 then begin mate:=false;break;end; Delete(datat,1,Length(t)); end; if datat<>'' then mate:=false; if mate then begin Delete(xml,1,pos('=',xml)+1); assign(input,path+'data'+Copy(xml,1,pos('"',xml)-1)); reset(input); assign(output,OutputFile); rewrite(output); while not eof do begin readln(t);writeln(t);end;break;end; until false;close(input);close(output); END.
具体改哪里我也不清楚·······································自己去他博客看下吧,我只是个蒟蒻
/*************************更新****************************/
qwq
前段时间无聊,又去网上搜AC自动机的相关介绍
然后搜到了这个qwq
好像更加适合实战的说……而且非常简单
嘛,也算是转载注明出处了qwq
收藏收藏
原理:
先读入n个数字(假设存在数组x[]里面),然后进入到评测软件的存数据的文件夹里面(一般文件夹名字叫data)
利用循环打开每一个输入文件,对比前n个数字,如果相同,那么基本可以确定找到了正确的读入文件(显然n越大准确率越高qwq)
记下这是第几组的输入文件,然后打开对应的输出数据读取内容,而后输出
AC……
//****代表输入输出文件名 #include <cstdio> #include <string> #include <iostream> char in[100001]; int x[10],id; std::string ans; int main() { freopen("****.in","r",stdin); freopen("****.out","w",stdout); for(int i=0;i<10;++i) scanf("%d",&x[i]); fclose(stdin); for(int i=1;i<=10;++i)//这里需要循环的范围是输入文件的个数 { sprintf(in,"..\..\data\****%d.in",i); freopen(in,"r",stdin); for(int xx,j=0;j<10;++j) { scanf("%d",&xx); if(x[j]!=xx)id=-1; } if(id==-1)continue; id=i; break; fclose(stdin); } sprintf(in,"..\..\data\****%d.ans",id); freopen(in,"r",stdin); std::cin>>ans; std::cout<<ans; //最后这部分输出仅适用于“输出一个数”的情况,其他情况需要修改(不是什么难事qwq) return 0; }