嗯,,,,自动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机的更多相关文章

  1. 论自动AC机

    O(∩_∩)O哈哈~第一篇原创博客.终于结束了我“无敌转载王”的称号了!!!好开心! (⊙v⊙)嗯,看到标题觉得我是神犇的人,请再次仔细看看标题,是“自动AC”,而非“AC自动”哦!这是利用lemon ...

  2. Censoring【自动AC机】【水题毁我青春】【20190614】

    这题简直比注水猪肉还水QAQ. 以前做过KMP的Censoring单串匹配,果断选择自动AC机w 对短串建自动AC机 长串去机子里匹配 用个栈边匹配边弹出 记得弹出一个串后把匹配点指向栈顶就ojbk ...

  3. 自动AC机qwq(大雾)以及trie图fail图的一些结论

    1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<string&g ...

  4. 自动AC机

    可以在lemon和cena环境下使用. #include<iostream> #include<cstdio> #include<cstring> #include ...

  5. 继续node爬虫 — 百行代码自制自动AC机器人日解千题攻占HDOJ

    前言 不说话,先猛戳 Ranklist 看我排名. 这是用 node 自动刷题大概半天的 "战绩",本文就来为大家简单讲解下如何用 node 做一个 "自动AC机&quo ...

  6. 三极管的妙用之C118自动刷机

    首先咱们要搞清楚咱们自动刷机的原理,不谈修改固件那么高深的东西,简单的就是控制开机键. 使用继电器来控制基本上算是上个世纪的想法吧,之前博主也做过,做出来的感觉其实也很不错,就像是一个收藏品.因为继电 ...

  7. BZOJ 1704: [Usaco2007 Mar]Face The Right Way 自动转身机( 贪心 )

    贪心...先枚举k, 然后从左往右扫一遍, 发现位置p的牛的状态不符合就将 [p, p + k ) 的牛都转身, 假如p + k - 1 已经超过了最右边牛的位置那这个k就不符合要求. 符合要求的就可 ...

  8. 【bzoj1704】[Usaco2007 Mar]Face The Right Way 自动转身机 贪心

    题目描述 农夫约翰有N(1≤N≤5000)只牛站成一排,有一些很乖的牛朝前站着.但是有些不乖的牛却朝后站着.农夫约翰需要让所有的牛都朝前站着.幸运的是约翰最近买了一个自动转身机.这个神奇的机器能使K( ...

  9. [bzoj1704][Usaco2007 Mar]Face The Right Way 自动转身机_贪心

    Face The Right Way 自动转身机 bzoj-1704 Usaco-2007 Mar 题目大意:不想描述题意系列++... ...题目链接 注释:略. 想法:我们直接枚举k,然后从左往右 ...

随机推荐

  1. voltdb数据库持久性,扩展集群

    之前在git上下载的voltdb,以及在官网下载的社区版voltdb均不支持持久性事务,和扩展集群,今天下载了企业试用版voltdb,安装过程不再赘述,记录一下我的使用过程 持久性测试 以前的 vol ...

  2. 我用的是python2,以后加python3的内容

    可能有的不成功,比如print 'abc',这时候确定下python版本,3的方式是print('abc')

  3. Linux学习---Linux用户审计简单版

    [root@localhost root]# vim /etc/profile # SHENJI history USER=`whoami` USER_IP=`who -u am i 2>/de ...

  4. Microsoft Teams 版本与语音落地介绍

    我亲爱的小伙伴们,失踪人口回归啦~~ 今天和大家聊的是Microsoft Teams,Teams作为协作的集大成者,可以实现skype for Business的所有功能,还可以在teams里集合Of ...

  5. 面向对象程序设计_课堂作业_01_Circle

    The 1st classwork of the C++ program 题目: Create a program that asks for the radius of a circle and p ...

  6. Alpha 冲刺报告(8/10)

    Alpha 冲刺报告(8/10) 队名:洛基小队 峻雄(组长) 已完成:关于角色属性的脚本编码 明日计划:提升脚本的完成度 剩余任务:角色的属性脚本 困难:缺乏编程经验,很难自己独立完成编写,只能根据 ...

  7. LRU算法的精简实现(基于Java)

    LRU(Least recently used,最近最少使用)算法根据数据的历史访问记录来进行淘汰数据,其核心思想是"如果数据最近被访问过,那么将来被访问的几率也更高". impo ...

  8. python第十四课--排序及自定义函数之自定义函数(案例一)

    案例一: 演示自定义函数的使用:包含:1).定义格式的掌握2).函数的好处 自定义函数:实现打印矩形的操作两个原则需要考虑:1).有没有形参?有,2个 2).有没有返回值?没有. def printR ...

  9. iOS应用内抓包、NSURLProtocol 拦截 APP 内的网络请求

    前言 开发中遇到需要获取SDK中的数据,由于无法看到代码,所以只能通过监听所有的网络请求数据,截取相应的返回数据,可以通过NSURLProtocol实现,还可用于与H5的交互 一.NSURLProto ...

  10. Python:numpy.newaxis

    x1[:,np.newaxis]:增维,转置 从字面上是插入新的维度的意思 demo1: 针对一维的情况 >>> b = np.array([1, 2, 3, 4, 5, 6]) & ...