对拍
2023-09-03 19:36:41 # Note

对拍

参考:参考文章1 参考文章2

数据

#include<bits/stdc++.h>
#include<sys/timeb.h>
using namespace std;
typedef long long ll;

ll Rand(ll mod)
{
    ll ans = INT_MAX;
    return ans * rand() % mod + 1;
}

int main()
{
    struct _timeb T;
    _ftime(&T);
    srand(T.millitm);
    mt19937 rd(T.millitm);
    ofstream file;
    file.open("a.in");
    int a = rd(), b = rd();
    file << a << ' ' << b;
    file.close();
    return 0;
}

或者:

#include<bits/stdc++.h>
#include<sys/timeb.h>
using namespace std;
typedef long long ll;

ll Rand(ll mod)
{
    ll ans = INT_MAX;
    return ans * rand() % mod + 1;
}

int main()
{
    struct _timeb T;
    _ftime(&T);
    srand(T.millitm);
    mt19937 rd(T.millitm);
    freopen("a.in","w",stdout);
    int a = rd(), b = rd();
    cout << a << ' ' << b;
    return 0;
}

暴力

#include<bits/stdc++.h>
using namespace std;
int main()
{
    freopen("a.in", "r", stdin);
    freopen("a.out", "w", stdout);
    int a, b;
    scanf("%d%d", &a, &b);
    printf("%d\n", a + b);
    return 0;
}

待测

#include<bits/stdc++.h>
using namespace std;
int main()
{
    freopen("a.in", "r", stdin);
    freopen("a.ans", "w", stdout);
    int a, b;
    scanf("%d%d", &a, &b);
    printf("%d\n", a + b);
    return 0;
}

对拍

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int ok = 0;
    int n = 20;
    system("cd E:/CodeProgram/CPP/Makers/Test/&g++ std.cpp -o std.exe&g++ baoli.cpp -o baoli.exe&g++ make.cpp -o make.exe");
    for(int i = 1; i <= n; i++)
    {
        system("cd E:/CodeProgram/CPP/Makers/Test/&make.exe&baoli.exe");
        double begin = clock();
        system("cd E:/CodeProgram/CPP/Makers/Test/&std.exe");
        double end = clock();
        double t = end - begin;
        if(system("cd E:/CodeProgram/CPP/Makers/Test/&fc a.out a.ans"))
        {
            printf("测试点 #%d Wrong Answer\n",i);
            fstream file;
            int a, b ;
            file.open("E:/CodeProgram/CPP/Makers/Test/a.in");
            if(file.good() && file.is_open())
                file >> a >> b;
            printf("输入:%d %d\n\n", a, b);
            file.close();
        }
        else if(t > 1000)
        {
            printf("测试点 #%d Time Limited Exeeded 用时 %.1fms\n\n", i, t);
        }
        else
        {
            printf("测试点 #%d Accepted 用时 %1.lfms\n\n", i, t);
            ok++;
        }
        printf("-------------------------------\n\n");
    }
    puts("");
    double res = 100.0 * ok / n;
    printf("共 %d 组测试数据,AC 数据 %d 组,得分:%.1lf。\n", n, ok, res);
    return 0;
}