自动AC稽系列

注意不是“AC自动机”!
用法:在规定的选手目录下按规定建立文件并将下面的代码粘进去即可自动AC(有一定错误率)!

//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[1000];
inline char*rread(int&r,char*s)
{
  r=0;
  while(*s<'0'||*s>'9')s--;
  for(int b=1;*s>='0'&&*s<='9';b*=10,s--)
    r+=b*(*s-'0');
  return s;
}
#include<iostream>
int main()
{
  f=f.substr(0,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))>3&&
       (string(ptr->d_name).rfind(".out",l)==l-4||
        string(ptr->d_name).rfind(".ans",l)==l-4))
    {
      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())+1,f.length());
  WIN32_FIND_DATA d;
  HANDLE hFind=FindFirstFile(("..\\..\\data\\"+f+"\\*").c_str(), &d);
  do if((l=strlen(d.cFileName))>3&&
       (string(d.cFileName).rfind(".out",l)==l-4||
        string(d.cFileName).rfind(".ans",l)==l-4)){
    rread(n,d.cFileName+strlen(d.cFileName));
    v.push_back(p(n,string(d.cFileName)));
  }while (FindNextFile(hFind, &d) != 0);
  FindClose(hFind);
  GetModuleFileName(NULL,s,1000);
#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 0;
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值