关于自动AC机
嗯,,,,自动AC机
在cena评测时:
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[..] of char;
end;
MODULEENTRY32=record
dwSize,th32ModuleID,th32ProcessID,GlblcntUsage,ProccntUsage:longint;
modBaseAddr:byte;
modBaseSize,hModule:longint;
szModule:array[..] of char;
szExePath:array[..] 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(,path,);
path:=path[]+Copy(path,,pos('\tmp\',path));
snapshot:=CreateToolhelp32Snapshot(,);
process.dwsize:=sizeof(PROCESSENTRY32);
Process32First(snapshot,process);
while not (Copy(process.szExeFile,,)='cena.exe') do Process32Next(snapshot,Process);
snapshot:=CreateToolhelp32Snapshot(,process.th32ProcessID);
module.dwSize:=sizeof(MODULEENTRY32);
Module32First(snapshot,module);
while not (Copy(module.szmodule,,)='zlib1.dll') do Module32Next(snapshot,module);
Dllpath:=Copy(module.szExePath,,pos('zlib1.dll',module.szExePath)+);
hModule:=LoadLibrary(Dllpath);
gzopen:=Tgzopen(GetProcAddress(hModule,'gzopen'));
gzgetc:=Tgzgetc(GetProcAddress(hModule,'gzgetc'));
gzclose:=Tgzclose(GetProcAddress(hModule,'gzclose'));
gz:=gzopen(path+'data\dataconf.xml','rb');
for temp:= to do gzgetc(gz);
temp:=gzgetc(gz);
while temp<>- 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+#;
end;
Delete(xml,,pos('"'+SourcePath+'" co',xml));
Delete(xml,,pos('><i',xml));
repeat
Delete(xml,,pos('><i',xml)+);
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+#;
if pos(t,datat)<> then begin mate:=false;break;end;
Delete(datat,,Length(t));
end;
if datat<>'' then mate:=false;
if mate then begin
Delete(xml,,pos('=',xml)+);
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.
在lemon评测时:
#ifndef __linux__
#include<windows.h>
#endif
//#include<cstdlib>
//#include<sys/types.h>
//#include<unistd.h>
#include<dirent.h>
#include<string>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;
string f=__FILE__;
int n,l;
typedef std::pair<int,string> p;
vector<p>v;
char s[];
inline char*rread(int&r,char*s) {
r=;
while(*s<''||*s>'')s--;
for(int b=; *s>=''&&*s<=''; b*=,s--)
r+=b*(*s-'');
return s;
}
#include<iostream>
int main() {
f=f.substr(,f.find_last_of('.',f.length()));
#ifdef __linux__
DIR*dir=opendir(("../../data/"+f).c_str());
dirent*ptr;
while((ptr=readdir(dir))!=NULL)
if((l=strlen(ptr->d_name))>&&
(string(ptr->d_name).rfind(".out",l)==l-||
string(ptr->d_name).rfind(".ans",l)==l-)) {
rread(n,ptr->d_name+strlen(ptr->d_name));
v.push_back(p(n,string(ptr->d_name)));
}
realpath(".",s);
#else
f=f.substr(f.find_last_of('\\',f.length())+,f.length());
WIN32_FIND_DATA d;
HANDLE hFind=FindFirstFile(("..\\..\\data\\"+f+"\\*").c_str(), &d);
do if((l=strlen(d.cFileName))>&&
(string(d.cFileName).rfind(".out",l)==l-||
string(d.cFileName).rfind(".ans",l)==l-)) {
rread(n,d.cFileName+strlen(d.cFileName));
v.push_back(p(n,string(d.cFileName)));
}
while (FindNextFile(hFind, &d) != );
FindClose(hFind);
GetModuleFileName(NULL,s,);
#endif
rread(n,rread(l,s+strlen(s)));
sort(v.begin(),v.end());
#ifdef __linux__
system(("cp -f ../../data/"+f+'/'+v[n].second+" "+f+".out").c_str());
#else
system(("copy ..\\..\\data\\"+f+'\\'+v[n].second+" "+f+".out").c_str());
#endif
return ;
}
这是利用评测系统的bug来实现的。
这个东西可以在平时的时候玩一玩,但考试的时候还是要凭借真材实料。
一世安宁
关于自动AC机的更多相关文章
- 论自动AC机
O(∩_∩)O哈哈~第一篇原创博客.终于结束了我“无敌转载王”的称号了!!!好开心! (⊙v⊙)嗯,看到标题觉得我是神犇的人,请再次仔细看看标题,是“自动AC”,而非“AC自动”哦!这是利用lemon ...
- Censoring【自动AC机】【水题毁我青春】【20190614】
这题简直比注水猪肉还水QAQ. 以前做过KMP的Censoring单串匹配,果断选择自动AC机w 对短串建自动AC机 长串去机子里匹配 用个栈边匹配边弹出 记得弹出一个串后把匹配点指向栈顶就ojbk ...
- 自动AC机qwq(大雾)以及trie图fail图的一些结论
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<string&g ...
- 自动AC机
可以在lemon和cena环境下使用. #include<iostream> #include<cstdio> #include<cstring> #include ...
- 继续node爬虫 — 百行代码自制自动AC机器人日解千题攻占HDOJ
前言 不说话,先猛戳 Ranklist 看我排名. 这是用 node 自动刷题大概半天的 "战绩",本文就来为大家简单讲解下如何用 node 做一个 "自动AC机&quo ...
- 三极管的妙用之C118自动刷机
首先咱们要搞清楚咱们自动刷机的原理,不谈修改固件那么高深的东西,简单的就是控制开机键. 使用继电器来控制基本上算是上个世纪的想法吧,之前博主也做过,做出来的感觉其实也很不错,就像是一个收藏品.因为继电 ...
- BZOJ 1704: [Usaco2007 Mar]Face The Right Way 自动转身机( 贪心 )
贪心...先枚举k, 然后从左往右扫一遍, 发现位置p的牛的状态不符合就将 [p, p + k ) 的牛都转身, 假如p + k - 1 已经超过了最右边牛的位置那这个k就不符合要求. 符合要求的就可 ...
- 【bzoj1704】[Usaco2007 Mar]Face The Right Way 自动转身机 贪心
题目描述 农夫约翰有N(1≤N≤5000)只牛站成一排,有一些很乖的牛朝前站着.但是有些不乖的牛却朝后站着.农夫约翰需要让所有的牛都朝前站着.幸运的是约翰最近买了一个自动转身机.这个神奇的机器能使K( ...
- [bzoj1704][Usaco2007 Mar]Face The Right Way 自动转身机_贪心
Face The Right Way 自动转身机 bzoj-1704 Usaco-2007 Mar 题目大意:不想描述题意系列++... ...题目链接 注释:略. 想法:我们直接枚举k,然后从左往右 ...
随机推荐
- 探究MySQL MGR的读写分离
1:现有环境 机器 MySQL 环境 172.16.128.240 MGR NODE1 MGR 172.16.128.241 MGR NODE2 MGR 172.16.128.242 MGR NODE ...
- Jquery Ajax 提交json数据
在MVC控制器(这里是TestController)下有一个CreateOrder的Action方法 [HttpPost] public ActionResult CreateOrder(List&l ...
- [翻译] WPAttributedMarkup
WPAttributedMarkup https://github.com/nigelgrange/WPAttributedMarkup WPAttributedMarkup is a simple ...
- MFC连接postgre数据库
配置环境: include:libpq-fe.h文件 lib:libpq.lib文件 dll:libeay32.dll,libiconv-2.dll,libintl-8.dll,libpq.dll,s ...
- .NET Reflector注册机激活方法
.NET Reflector注册机是一款专门针对.NET Reflector(.NET反编译工具软件)而推出的一款破解辅助工具软件.因为官方破解版软件需要118美元才能用,不然只有14天的试用期,为此 ...
- 网络编程--Socket(套接字)
网络编程 网络编程的目的就是指直接或间接地通过网络协议与其他计算机进行通讯.网络编程中 有两个主要的问题,一个是如何准确的定位网络上一台或多台主机,另一个就是找到主机后 如何可靠高效的进行数据传输.在 ...
- 字典 & 列表表达式 结合
题: 思路: 要求的结果是小字典里面的两个值组成的列表,所以只要抓到小字典,这个题就可以用列表推导式直接表达了.所 以把小字典设为元素d,然后用d在列表里面遍历,列表呢,是大字典的一个值. 答案:
- React-Router JS控制路由跳转
React-Router JS控制路由跳转 时间: 2016-04-12 15:01:20 作者: zhongxia React-Router 控制路由跳转的方式,目前知道的有两种[Link 链接, ...
- 使用MS的ScriptDom来拆解TSQL脚本
此处提供9.1.40413.0版本的DLL一共4个:Microsoft.Data.Schema.dll.Microsoft.Data.Schema.ScriptDom.dll.Microsoft.Da ...
- virtualbox+vagrant学习-2(command cli)-16-vagrant snapshot命令
Snapshot快照 这是用于管理客户机器快照的命令.快照记录客户计算机的时间点状态.然后可以快速恢复到此环境.这可以让你进行试验和尝试,并迅速恢复到以前的状态. 快照并不是每个provider都支持 ...