QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#732456#5140. Frozen Scoreboardheyuhao#Compile Error//C++203.9kb2024-11-10 14:37:292024-11-10 14:37:31

Judging History

你现在查看的是最新测评结果

  • [2024-11-10 14:37:31]
  • 评测
  • [2024-11-10 14:37:29]
  • 提交

answer

#pragma GCC optimize(3, "Ofast", "inline")
#include <iostream>
#include<map>
#include<vector>
//  #include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define INF 0x3f3f3f3f
#define L_INF 0x7f3f3f3f3f3f3f3f
#define db cout << "debug\n";

using namespace std;
const int Mod = 998244353;
using ll = long long;
int m;
struct problem
{
    int index;
    int flag;               //flag {0,没做} {1,过了} {2,没过} {3,可能过}
    int sub,time,sub_time;  // sub 提交次数 time 罚时 sub_time 提交时间
    int bef,aft;            // bef 封榜前提交 aft 封榜后提交
    int most,least;         //most 最多罚时 least 最少罚时
    bool st;
}p[14];
bool cmp(problem a,problem b)
{
    if(a.most!=b.most)
        return a.most>b.most;
    return a.least<b.least;
}
void solve()
{
    int num,time;
    cin>>num>>time;
    vector<problem> all;
    for(int i=1;i<=m;i++)
    {
        p[i].index=i;
        string s;
        cin>>s;
        if(s=="+")
        {
            p[i].flag=1;
            string ss;
            cin>>ss;
            int pos=0;
            p[i].sub=0;
            while(ss[pos]!='/')
            {
                p[i].sub=p[i].sub*10+ss[pos]-'0';
                pos++;
            }
            p[i].time=0;
            for(int j=pos+1;j<ss.size();j++)
            {
                p[i].time=p[i].time*10+ss[j]-'0';
            }
            p[i].sub_time=p[i].time;
            p[i].time+=(p[i].sub-1)*20;
        }
        else if(s=="?")
        {
            p[i].flag=3;
            int x,y;
            cin>>x>>y;
            p[i].bef=y-x;
            p[i].aft=x;
            p[i].most=299+20*(y-1);
            p[i].least=240+20*(p[i].bef);
            p[i].st=false;
            all.push_back(p[i]);
        }
        else if(s=="-")
        {
            p[i].flag=2;
            cin>>p[i].sub;
        }
        else
        {
            p[i].flag=0;
        }
    }
    int now_num=0,now_time=0;
    for(int i=1;i<=m;i++)
    {
        if(p[i].flag==1)
        {
            now_num++;
            now_time+=p[i].time;
        }

    }
    // cout<<now_num<<" "<<now_time<<"\n";
    if(num<now_num||num==now_num&&time!=now_time||num>now_num&&(now_num+all.size()<num))
    {
        cout<<"No\n";
        return;
    }
    int new_sub=num-now_num,new_time=time-now_time;
    new_time-=new_sub*240;
    if(new_time<0)
    {
        cout<<"No\n";
    }
    sort(all.begin(),all.end(),cmp);
    for(auto &c:all)
    {
        if(new_time<c.bef*20)
            continue;
        new_time-=c.bef*20;
        c.st=true;
        int atf=min(c.aft-1,new_time/20);
        new_time-=atf*20;
        int aftt=min(59,new_time);
        new_time-=aftt;
        c.sub=c.bef+atf+1;
        c.sub_time=240+aftt;
        if(new_time==0)
            break;
    }
    for(auto &c:all)
    {
        if(c.st)
        {
            int pos=c.index;
            p[pos].flag=1;
            p[pos].sub=c.sub;
            p[pos].sub_time=c.sub_time;
        }
        else
        {
            int pos=c.index;
            p[pos].flag=2;
            p[pos].sub=c.bef+c.aft;
        }
    }
    cout<<"Yes\n";
    for(int i=1;i<=m;i++)
    {
        if(p[i].flag==0)
        {
            cout<<".\n";
        }
        else if(p[i].flag==1)
        {
            cout<<"+ "<<p[i].sub<<"/"<<p[i].sub_time<<"\n";
        }
        else if(p[i].flag==2)
        {
            cout<<"- "<<p[i].sub<<"\n";
        }
    }
}
int main()
{
    IOS;
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
#ifndef ONLINE_JUDGE
    clock_t start_time = clock();
#endif
    int t;
    t = 1;
    cin >> t>>m;
    while (t--)
    {
        solve();
    }
#ifndef ONLINE_JUDGE
    cout << "Used " << (double)(clock() - start_time) << " ms" << endl;
#endif
    return 0;
}

詳細信息

answer.code: In function ‘void solve()’:
answer.code:104:5: error: ‘sort’ was not declared in this scope; did you mean ‘short’?
  104 |     sort(all.begin(),all.end(),cmp);
      |     ^~~~
      |     short