【自用】Scoring Script Generator

· · 个人记录

#include <bits/stdc++.h>
using namespace std;
FILE *f;
int n;
int main()
{
    f=fopen("result.txt","wb");
    cout<<"Please input the number of subtasks."<<endl;
    cin>>n;
    fprintf(f,"@final_time = 0;\n@final_memory = 0;\n@final_status=AC;\n@total_score=0;\n");
    for(int i=1;i<=n;++i)
    {
        cout<<"Please input the ids of the subtasks of which subtask #"<<i<<" is dependent."<<endl;
        cout<<"Examples: '-' ({}) '4021' ({1,2,4}) '6CF' ({6,12,15}) '1a' ({1,10}) 'g64' ({4,6,16}) "<<endl;
        string s;cin>>s;
        for(char c:s)
        {
            if('1'<=c&&c<='9'||'A'<=c&&c<='Z'||'a'<=c&&c<='z')
            {
                int x=0;
                if('1'<=c&&c<='9') x=(c-'0');
                if('A'<=c&&c<='Z') x=(c-'A')+10;
                if('a'<=c&&c<='z') x=(c-'a')+10;
                fprintf(f,"if (@score%d == 0); then\n    @score%d = 0;\nfi\n",x,i);
            }
        }
        fprintf(f,"if(@time%d > @final_time); then\n    @final_time = @time%d;\nfi\n",i,i);
        fprintf(f,"if(@memory%d > @final_memory); then\n    @final_memory = @memory%d;\nfi\n",i,i);
        fprintf(f,"if(@status%d != AC); then\n    @final_status=UNAC;\nfi\n",i);
        fprintf(f,"@total_score = @total_score + @score%d ;\n",i);
    }
    return 0;
}