关于自动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,然后从左往右 ...
随机推荐
- VS2017 加载项目 :未找到框架“.NETFramework,Version=v4.7”的引用程序集(出坑指南)
报出的错误为: 错误MSB3644: 未找到框架“.NETFramework,Version=v4.7”的引用程序集.若要解决此问题,请安装此框架版本的 SDK 或 Targeting Pack,或将 ...
- [翻译] IDMPhotoBrowser
IDMPhotoBrowser IDMPhotoBrowser is a new implementation based on MWPhotoBrowser. IDMPhotoBrowser实现了图 ...
- DES加密(支持ARC与MRC)
DES加密(支持ARC与MRC) 源文件: YXCrypto.h 与 YXCrypto.m // // YXCrypto.h // 用秘钥给字符串加密或者解密 // // Created by You ...
- [翻译] UIGlossyButton
UIGlossyButton https://github.com/waterlou/UIGlossyButton Feature create standard iPhone buttons wit ...
- wordpress利用rsync同步备份
我搭建的wordpress服务器现在使用的系统是opensuse, 服务器上面已做脚本和计划任务将wordpress使用的数据库与web目录每天压缩备份放到 /data/backup目录下 opera ...
- JS DateTime 格式化
首先看我们在浏览器接收到的DateTime格式的数据: 如果没有在传输的时候把DateTime转成字符串的话,我们只需要在JS中加一段代码即可转换,代码如下: function ChangeDateF ...
- Maven实战系列文章目录
Maven实战(一)安装与配置 Maven实战(二)构建简单Maven项目 Maven实战(三)Eclipse构建Maven项目 Maven实战(四)生命周期 Maven实战(五)坐标详解 Maven ...
- java一个字符串中出现次数最多的字符以及次数
学习了别人的方法,觉得挺巧妙的.就是每次取出字符串的第一个字符,将字符串中与第一个字符相同的字符全部删除掉,然后通过计算删除前后字符串的长度来确定该字符在字符串中出现的次数,最终比较出出现最多次的字符 ...
- 1084. [SCOI2005]最大子矩阵【网格DP】
Description 这里有一个n*m的矩阵,请你选出其中k个子矩阵,使得这个k个子矩阵分值之和最大.注意:选出的k个子矩阵 不能相互重叠. Input 第一行为n,m,k(1≤n≤100,1≤m≤ ...
- Hive学习之路 (七)Hive的DDL操作
库操作 1.创建库 语法结构 CREATE (DATABASE|SCHEMA) [IF NOT EXISTS] database_name [COMMENT database_comment] //关 ...