跳到正文

个人记录

互相给一巴掌数据统计器

tiger2005约 8 分钟
原文

这是 2025年9月10日 存档的第 1 版,不是当前版本。查看当前版本

文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月18日
篇幅
约 8 分钟

版本

  1. v2当前
  2. v1

在这个的基础上,先输入一个字符串(不要有/),表示这次测试的名称

C++
#include<cstring>
#include<windows.h>
#include<string>
#include<iostream>
#include<ctime>
#include<fstream>
#include<algorithm>
#include<sstream>
using namespace std;
const char* a;
string ra,so,bf,p,str1,str2,an,dirName,emm;
int N,l1,l2,fk[7][6],mb,jl[1000001][2],mp;
double st,en;
string GetProgramDir(){   
    char exeFullPath[1010];
    string strPath = "";
    GetModuleFileName(NULL,exeFullPath,MAX_PATH);
    strPath=(string)exeFullPath;
    int pos = strPath.find_last_of('\\', strPath.length());
    return strPath.substr(0, pos);
}   
void colset(double a){
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),a);
}
bool ws(char a){
    return a=='\t' || a=='\n' || a=='\r' || a==' ' || a==EOF;
}
bool bj(){
    if(l1!=l2)  return true;
    for(int i=0;i<=l1&&i<=l2;i++){
        if(str1[i]!=str2[i])    return true;
    }
    return false;
}
double ss(int i){
    if(i>=1000) return 12;
    else if(i<200)  return 13;
    else if(i<400)  return 9;
    else if(i<600)  return 11;
    else if(i<800)  return 10;
    return 14;
}
int sts(int i){
    if(i>=1000) return 5;
    else if(i<200)  return 0;
    else if(i<400)  return 1;
    else if(i<600)  return 2;
    else if(i<800)  return 3;
    return 4;
}
int ssts(int i,int j){
    for(int k=0;k<6;k++){
        if(i>(j*k/6) && i<=(j*(k+1)/6)) return k;
    }
    return 0;
}
long long anss=0;
int main(){
    printf("TIMESET:\n");
    for(int i=0;i<1000;i+=200){
        colset(ss(i));
        printf("%d ~ %d\n",i,i+199);
    }
    colset(ss(1000));
    printf("1000+\n");
    colset(7);
    printf("Text name:\n");
    cin >> an;
    dirName=GetProgramDir()+"\\"+an;
    CreateDirectory(dirName.c_str(),NULL);
    dirName+='\\';
    printf("Random exe:\n");
    cin >> ra;
    printf("Correct exe(It doesn\'t matter if it is TLE):\n");
    cin >> bf;
    printf("Your exe:\n");
    cin >> so;
    printf("Text Number:\n");
    cin >> N;
    if(N>1000000){
        printf("BIGGER THAN 1000000!!!\n");
        return 0;
    }
    for(int i=1;i<=N;i++){
        stringstream stts;
        stts<<i;
        string ono;
        stts>>ono;
        emm=dirName+ono;
        CreateDirectory(emm.c_str(),NULL);
        p=ra+" > "+emm+"\\"+"input.txt";
        a=p.c_str();
        system(a);
        p=bf+" < "+emm+"\\"+"input.txt > "+emm+"\\"+"answer.txt";
        a=p.c_str();
        system(a);
        p=so+" < "+emm+"\\"+"input.txt > "+emm+"\\"+"ouput.txt";
        a=p.c_str();
        st=clock();
        system(a);
        en=clock();
        ifstream f1;
        f1.open((emm+"\\"+"ouput.txt").c_str());
        str1.clear();
        str2.clear();
        l1=-1;
        while(!f1.eof())    str1+=f1.get(),++l1;
        f1.close();
        f1.open((emm+"\\"+"answer.txt").c_str());
        l2=-1;
        while(!f1.eof())    str2+=f1.get(),++l2;
        f1.close();
        while(l1>=0 && ws(str1[l1]))    --l1;
        while(l2>=0 && ws(str2[l2]))    --l2;
        bool ac=true;
        if(bj()){
            colset(12);
            printf("### Wrong answer, TEXT:%d\n",i);
            colset(7);
            ac=false;
        }
        else    colset(ss(int(en-st))),printf("Accepted, TEXT:%d, TIME:%.0lfms OUPUT_BIT:%d\n",i,en-st,l2+1);
        ofstream f2;
        f2.open((emm+"\\"+"result.txt").c_str());
        f2<<"输出大小:"<<l2+1<<"bits\n";
        f2<<"状态:"<<(ac?"Accepted":"Wrong answer")<<"\n";
        if(ac)  f2<<"TIME:"<<en-st<<"ms"<<endl;
        f2.close();
        jl[i][0]=l2+1;
        jl[i][1]=en-st;
        anss+=(en-st);
        mb=max(mb,l2+1);
    }
    mp=mb;mb/=6;++mb;
    colset(10);printf("OK!!!\n");
    for(int i=1;i<=N;i++)   ++fk[ssts(jl[i][0],mp)][sts(jl[i][1])];
    for(int i=0;i<6;i++){
        colset(ss(i*200));
        if(i!=5)    printf("%d ~ %d ms => %d\n",i*200,i*200+199,fk[0][i]+fk[1][i]+fk[2][i]+fk[3][i]+fk[4][i]+fk[5][i]);
        else    printf("%d+ ms => %d\n",i*200,fk[0][i]+fk[1][i]+fk[2][i]+fk[3][i]+fk[4][i]+fk[5][i]);
    }
    printf("Average:%gms\n",anss*1.0/N);
    colset(7);
    system("pause");
    return 0;
}