造福后人
查看原帖
造福后人
1201196
Zhenghw楼主2025/6/14 21:11

本题的checker如下,直接把编译好的活动文件和你的答案放在同一个文件夹里运行就可以看到测评结果了。

#include<cmath>
#include<cstring>
#include<sstream>
#include<fstream>
#include<iostream>
using namespace std;
constexpr int N=1001,M=1e5;
constexpr int L0[15]={0,3,9,233,1,10,29,14,7,18,14};
string ss;
ifstream fcin;
stringstream scin;
int i,k,n,L,id,cnt,score,p[N];
bool (*task[15])(int),AC=true;
class Statement{
    public:
        int x,y,l,type;
        inline bool init(int i){
            scin>>ss;
            if(ss=="new"){
                type=1;
                scin>>x;
            }else if(ss=="dec"){
                type=2;
                scin>>x;
            }else if(ss=="assign"){
                type=3;
                scin>>x>>y;
                if(y<1) return true;
            }else if(ss=="iftry"){
                type=4;
                scin>>x>>ss>>l;
                if(ss!="goto"||l<1||l>=N)
                    return true;
            }else if(ss=="ifeq"){
                type=5;
                scin>>x>>y>>ss>>l;
                if(ss!="goto"||y<1||l<1||l>=N)
                    return true;
            }else if(ss=="ifneq"){
                type=6;
                scin>>x>>y>>ss>>l;
                if(ss!="goto"||y<1||l<1||l>=N)
                    return true;
            }else return true;
            if(x>=N||y>=N||l>=N||x<1)
                return true;
            return false;
        }inline void run(){
            if(type==1) i++,p[x]=++n;
            else if(type==2) i++,p[x]--;
            else if(type==3) i++,p[x]=p[y];
            else if(type==4)
                p[x]>=0?(i=l):i++;
            else if(type==5)
                p[x]==p[y]?(i=l):i++;
            else if(type==6)
                p[x]!=p[y]?(i=l):i++;
            
        }
}s[N];
inline int gcd(int x,int y){
    while(y^=x^=y^=x%=y);
    return x;
}inline bool check1(const int n){
    return n!=k<<1;
}inline bool check2(const int n){
    return n!=k*(k-1)>>1;
}inline bool check3(const int n){
    return n!=600;
}inline bool check4(const int n){
    return n!=k+1;
}inline bool check5(const int n){
    return n!=k*k-1;
}inline bool check6(const int n){
    return n!=k+2000;
}inline bool check7(const int n){
    return n!=int(k+log(k)/log(2));
}inline bool check8(const int n){
    return n!=k+k%2+1;
}inline bool check9(const int n){
    return n!=k+gcd(k,k-4)+1;
}inline bool check10(const int n){
    return fabs(n-k*log(k))>30;
}inline void show(const int s){
    if(s<10) AC=false;
    score+=s;
    cout<<"You got "<<s<<" points in test "<<id<<".\n";
}inline bool compile(){
    cout<<"Compiling...\n";
    fcin.open(ss);
    fcin>>L,fcin.ignore();
    if(L>=N){
        cout<<"Your code is too long.\n";
        return true;
    }else if(L<=0){
        cout<<"The number of lines in your code is incorrect.\n";
        return true;
    }for(i=1;i<=L;i++){
        getline(fcin,ss);
        scin<<ss;
        if(s[i].init(i)){
            cout<<"Compile Error\n";
            cout<<"Compile error on line "<<i<<".\n";
            return true;
        }scin.clear();
    }fcin.close();
    return false;
}inline int run(){
    for(k=5;k<=100;k++){
        memset(p,0,sizeof p);
        cnt=0,p[1]=n=k;
        for(i=1;i<=L&&cnt<M;cnt++)
            s[i].run();
        if(cnt==M){
            cout<<"Time Limit Exceeded\n";
            return 0;
        }else if(task[id](n)){
            cout<<"Wrong Answer\n";
            cout<<"Your answer is wrong when n="<<k<<".\n";
            return 0;
        }
    }if(L0[id]>L) return 11;
    else return floor(10/(exp(1-1.0*L0[id]/L)));
}inline void judge(){
    cout<<"Judging on test "<<id<<".\n";
    if(id<10) ss=char(id+48);
    else ss+="10";
    ss+=".out";
    if(compile()) show(0);
    else show(run());
}int main(){
    task[1]=check1;
    task[2]=check2;
    task[3]=check3;
    task[4]=check4;
    task[5]=check5;
    task[6]=check6;
    task[7]=check7;
    task[8]=check8;
    task[9]=check9;
    task[10]=check10;
    for(id=1;id<=10;id++)
        judge();
    cout<<"Result:"<<score<<"pts "<<(AC?"Accepted":"Unaccepted")<<'\n';
    return 0;
}
2025/6/14 21:11
加载中...