嗯,,,,自动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. 将虚拟网络连接到 ExpressRoute 线路

    本文通过使用 Resource Manager 部署模型和 Azure 门户,帮助将虚拟网络 (VNets) 链接到 Azure ExpressRoute 线路. 虚拟网络可以在同一个订阅中,也可以属 ...

  2. sql server 查询ntext字段长度

    DATALENGTH 返回任何表达式所占用的字节数. 语法 DATALENGTH ( expression ) 参数 expression 任何类型的表达式. 返回类型 int 注释 DATALENG ...

  3. [翻译] USING GIT IN XCODE [5] 在XCODE中使用GIT[5]

    USING GIT IN XCODE USING BRANCHES Branches can be a very effective tool to isolate new features or e ...

  4. Test checkout of feature 'Compiler' failed 解决方法(转载)

    Test checkout of feature 'Compiler' failed.   2014a的解决办法 适用于已安装compiler但破解不完全的, ht—tp://pan.baidu.co ...

  5. JS和css实现检测移动设备方向的变化并判断横竖屏幕

    这篇文章主要介绍了JS和css实现检测移动设备方向的变化并判断横竖屏幕,本文分别给出实现代码,需要的朋友可以参考下 方法一:用触发手机的横屏和竖屏之间的切换的事件  [自测可用, chrome , 手 ...

  6. 解决Struts2 json-plugin Date或Timestamp等日期格式带T的问题

    如果没有对日期时间对象类进行json日期格式声明,会出现类似"2013-06-18T12:08:56.23"日期,在日期中间多出一个T字母: 从通过查询数据,以及调试程序发现直到返 ...

  7. Linux环境变量配置文件/etc/profile、/etc/bashrc、~/.bashrc的区别以及一些隐藏文件的作用

    ①/etc/profile: 该文件登录操作系统时,为每个用户设置环境信息,当用户第一次登录时,该文件被执行.也就是说这个文件对每个shell都有效,用于获取系统的环境信息. ②/etc/bashrc ...

  8. python 二维数组键盘输入

    m = int(input()) grid = [[] for i in range(m)] for i in range(m): line = input().split(' ') for j in ...

  9. 第三部分 OpenStack镜像管理

    一.简介 很多源都有为OpenStack已经编译好的各种镜像了,您可以直接下载并通过使用这些镜像来熟悉OpenStack. 不过如果是为生产环境进行部署的话,您一定需要构建含有定制软件或配置的镜像文件 ...

  10. 正则表达式详解<一>

    正则表达式是一种处理字符串的微型语言:有以下的基本术语: l  模式(pattern):正则表达式实际上是通过字符串表达的一个模式 l  匹配(match): 判断正则表达式和给出的序列[first ...