QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#759026#9530. A Game On TreeW_Trace2#Compile Error//C++202.8kb2024-11-17 21:15:172024-11-17 21:15:17

Judging History

This is the latest submission verdict.

  • [2024-11-17 21:15:17]
  • Judged
  • [2024-11-17 21:15:17]
  • Submitted

answer

#include<bits/stdc++.h>
#define ll long long
using namespace std;
inline ll read(){
	ll a=0,b=1;char c=getchar();
	for(;c<'0'||c>'9';c=getchar())if(c=='-')b=-1;
	for(;c>='0'&&c<='9';c=getchar())a=a*10+c-'0';
	return a*b;
}
struct Charge
{
    ll next_sta,rest,Kind,Rank;
    friend operator< (Charge a,Charge b)
    {
        return a.next_sta>b.next_sta;
    }
};
ll n,m,a[100001];
priority_queue<Charge> use,charge;
vector<ll> position[100001];
int two_point(int x,int place)//第一个大于的位置
{
    int l=0,r=position[x].size()-1;
    while(l<r)
    {
        int mid=l+r>>1;
        if(position[x][mid]<=place)
            l=mid+1;
        else 
            r=mid;
    }
    return l;
}
int main()
{
    ll T=read();
    while(T--)
    {
        n=read(),m=read();
        for(ll i=1;i<=n;i++)
        {
            a[i]=read();
            position[i].clear();
        }
        for(ll i=1;i<=m;i++)
        {
            ll x=read(),y=read();
            position[y].push_back(x);
        }
        for(ll i=1;i<=n;i++)
        {
            sort(position[i].begin(),position[i].end());
            position[i].push_back((1LL<<60));
        }
        for(ll i=1;i<=n;i++)
        {
            Charge x;
            x.Kind=i;
            x.next_sta=position[i][0];
            x.Rank=0;
            x.rest=a[i];
            use.push(x);
        }
        int nowp=0;
        // cout<<"?\n";
        Charge tmp;
        tmp.next_sta=(1LL<<60);
        charge.push(tmp);
        while(use.size()!=0)
        {
            
            if(use.top().rest+nowp<=min(use.top().next_sta,(charge.top().next_sta)))
            {
                nowp+=use.top().rest;
                Charge x=use.top();
                use.pop();
                x.rest=0;
                charge.push(x);
            }
            else
            {
                Charge x=use.top();
                Charge y=charge.top();
                if(x.next_sta<=y.next_sta)
                {
                    use.pop();
                    nowp=x.next_sta;
                    x.rest=a[x.Kind];
                    x.next_sta=position[x.Kind][two_point(x.Kind,nowp)];
                    use.push(x);
                }
                else
                {
                    use.pop();
                    x.rest-=(y.next_sta-nowp);
                    nowp+=(y.next_sta-nowp);
                    use.push(x);
                    charge.pop();
                    y.next_sta=position[y.Kind][two_point(y.Kind,nowp)];
                    y.rest=a[y.Kind];
                    use.push(y);
                }

            }
            
        }
        cout<<nowp<<'\n';
    }
    return 0;
}
/*
1
3 1
3 3 3
8 1
1
2 2
5 2
1 2
2 1
*/

详细

answer.code:13:12: error: ISO C++ forbids declaration of ‘operator<’ with no type [-fpermissive]
   13 |     friend operator< (Charge a,Charge b)
      |            ^~~~~~~~