首页 > 其他 > 详细

对拍程序

时间:2021-01-17 21:43:00      阅读:41      评论:0      收藏:0      [点我收藏+]

random.cpp

#include <bits/stdc++.h>
#define ULL unsigned long long
#define LL long long
using namespace std;

ULL random(ULL mod){return ((ULL)rand() << 4 | (ULL)rand() << 19 | (ULL)rand() << 34 | (ULL)rand() << 49 | rand() & 15) % mod;}
LL random(LL l,LL r){return random(r - l + 1) + l;}
LL prandom(LL l,LL r,char c){LL ret = random(l, r); printf("%lld%c", ret, c); return ret;}

int main(){
    srand(time(NULL));
    freopen("data.in", "w", stdout);
    //example
    int n = prandom(100, 200, \n);
    for(int i=1; i<=n; i++) prandom(1, 10, " \n"[i==n]);
    int q = prandom(100, 200, \n);
    for(int i=1; i<=q; i++){
        int l = random(1, n), r = random(1, n);
        if(l > r) swap(l, r);
        printf("%d %d\n", l, r);
    }
    //example
    return 0;
}

compare.cpp

#include <bits/stdc++.h>
using namespace std;

int main(){
    int T = 100;
    for(int i=1; i<=T; i++){
        system("random.exe"), system("right.exe"), system("wrong.exe");
        if(system("fc data.ans data.out")) break;
    }
    return 0;
}

wrong.cpp

...
int main(){
    freopen("data.in", "r", stdin);
    freopen("data.out", "w", stdout);
...
return 0; }

right.cpp

...
int main(){
    freopen("data.in", "r", stdin);
    freopen("data.ans", "w", stdout);
    ...
    return 0;
}

对拍程序

原文:https://www.cnblogs.com/PHDHD/p/14290018.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!