QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#397583#5308. RPG Pro LeaguemarherCompile Error//C++141.8kb2024-04-24 13:37:242024-04-24 13:37:25

Judging History

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

  • [2024-04-24 13:37:25]
  • 评测
  • [2024-04-24 13:37:24]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+50,inf=1e9;

int n,c[N],k,p[N],m,d[N],f[18],g[N];
ll ans;map<string,int>mp;string s[N];

struct node
{
    int w,x;

    bool operator<(node b)
    {
        return w==b.w?x<b.x:w<b.w;
    }
};

multiset<node>S[20][2];

bool cmp(int a,int b)
{
    return c[a]>c[b];
}

void add(int x)
{
    int F=g[x]?-1:1;ans+=c[x]*F;
    for(int i=1;i<=15;i++)if(i&p[x])f[i]+=F;
    g[x]^=1;
}

int sol()
{
    int ans=inf;
    for(int i=1;i<=15;i++)ans=min(ans,f[i]/__popcount(i));
    return ans;
}

main()
{
    mp["B"]=1;mp["D"]=10;mp["S"]=12;mp["BD"]=11;mp["BS"]=13;mp["DS"]=14;mp["BDS"]=15;
    cin>>n;
    for(int i=1;i<=n;i++)cin>>s[i]>>c[i],sort(s[i].begin(),s[i].end()),p[i]=mp[s[i]],d[i]=i;
    sort(d+1,d+1+n,cmp);
    for(int i=1;i<=n;i++)add(i);k=sol();
    for(int i=1;i<=n;i++)
    {
        add(d[i]);
        if(sol()<k)add(d[i]);
    }
    for(int i=1;i<=n;i++)S[p[i]][g[i]].insert((node){c[i],i});
    cin>>m;
    while(m--)
    {
        int x,w,t=g[x];cin>>x>>w;ans-=t*(c[x]-w);
        S[p[x]][t].erase((node){c[x],x});c[x]=w;
        S[p[x]][t].insert((node){c[x],x});
        int v=0;ll val=ans;
        for(int i=1;i<=15;i++)
        {
            int u=0;
            if(t)u=S[i][0].empty()?0:(*S[i][0].begin()).x;
            else u=S[i][1].empty()?0:(*prev(S[i][1].end())).x;
            if(u)
            {
                add(x);add(u);
                if(sol()==k&&ans<val)val=ans,v=u;
                add(x);add(u);
            }
        }
        if(v)S[p[x]][g[x]].erase((node){c[x],x}),S[p[v]][g[v]].erase((node){c[v],v}),add(x),add(v),S[p[x]][g[x]].insert((node){c[x],x}),S[p[v]][g[v]].insert((node){c[v],v});
        cout<<ans<<'\n';
    }
}

Details

answer.code:40:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
   40 | main()
      | ^~~~
In file included from /usr/include/c++/13/string:49,
                 from /usr/include/c++/13/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52,
                 from answer.code:1:
/usr/include/c++/13/bits/stl_function.h: In instantiation of ‘constexpr bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = node]’:
/usr/include/c++/13/bits/stl_tree.h:2149:32:   required from ‘std::pair<std::_Rb_tree_node_base*, std::_Rb_tree_node_base*> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_get_insert_equal_pos(const key_type&) [with _Key = node; _Val = node; _KeyOfValue = std::_Identity<node>; _Compare = std::less<node>; _Alloc = std::allocator<node>; key_type = node]’
/usr/include/c++/13/bits/stl_tree.h:2198:4:   required from ‘std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_equal(_Arg&&) [with _Arg = node; _Key = node; _Val = node; _KeyOfValue = std::_Identity<node>; _Compare = std::less<node>; _Alloc = std::allocator<node>; iterator = std::_Rb_tree<node, node, std::_Identity<node>, std::less<node>, std::allocator<node> >::iterator]’
/usr/include/c++/13/bits/stl_multiset.h:510:36:   required from ‘std::multiset<_Key, _Compare, _Alloc>::iterator std::multiset<_Key, _Compare, _Alloc>::insert(value_type&&) [with _Key = node; _Compare = std::less<node>; _Alloc = std::allocator<node>; iterator = std::_Rb_tree<node, node, std::_Identity<node>, std::less<node>, std::allocator<node> >::const_iterator; value_type = node]’
answer.code:52:46:   required from here
/usr/include/c++/13/bits/stl_function.h:408:20: error: no match for ‘operator<’ (operand types are ‘const node’ and ‘const node’)
  408 |       { return __x < __y; }
      |                ~~~~^~~~~
answer.code:13:10: note: candidate: ‘bool node::operator<(node)’ (near match)
   13 |     bool operator<(node b)
      |          ^~~~~~~~
answer.code:13:10: note:   passing ‘const node*’ as ‘this’ argument discards qualifiers
In file included from /usr/include/c++/13/bits/stl_algobase.h:64,
                 from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51:
/usr/include/c++/13/bits/stl_pair.h:835:5: note: candidate: ‘template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)’
  835 |     operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
      |     ^~~~~~~~
/usr/include/c++/13/bits/stl_pair.h:835:5: note:   template argument deduction/substitution failed:
/usr/include/c++/13/bits/stl_function.h:408:20: note:   ‘const node’ is not derived from ‘const std::pair<_T1, _T2>’
  408 |       { return __x < __y; }
      |                ~~~~^~~~~
In file included from /usr/include/c++/13/bits/stl_algobase.h:67:
/usr/include/c++/13/bits/stl_iterator.h:455:5: note: candidate: ‘template<class _Iterator> bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)’
  455 |     operator<(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/13/bits/stl_iterator.h:455:5: note:   template argument deduction/substitution failed:
/usr/include/c++/13/bits/stl_function.h:408:20: note:   ‘const node’ is not derived from ‘const std::reverse_iterator<_Iterator>’
  408 |       { return __x < __y; }
      |                ~~~~^~~~~
/usr/include/c++/13/bits/stl_iterator.h:500:5: note: candidate: ‘template<class _IteratorL, class _IteratorR> bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)’
  500 |     operator<(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/13/bits/stl_iterator.h:500:5: note:   template argument deduction/substitution failed:
/usr/include/c++/13/bits/stl_function.h:408:20: note:   ‘const node’ is not derived from ‘const std::reverse_iterator<_Iterator>’
  408 |       { return __x < __y; }
      |                ~~~~^~~~~
/usr/include/c++/13/bits/stl_iterator.h:1705:5: note: candidate: ‘template<class _IteratorL, class _IteratorR> bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)’
 1705 |     operator<(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/13/bits/stl_iterator.h:1705:5: note:   template argument deduction/substitution failed:
/usr/include/c++/13/bits/stl_function.h:408:20: note:   ‘const node’ is not derived from ‘const std::move_iterator<_IteratorL>’
  408 |       { return __x < __y; }
      |                ~~~~^~~~~
/usr/include/c++/13/bits/stl_iterator.h:1770:5: note: candidate: ‘template<class _Iterator> bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)’
 1770 |     operator<(const move_iterator<_Iterator>& __x,
      |     ^~~~~~~~
...