QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#621101#8230. SubmissionswxgmjfhyCompile Error//C++203.2kb2024-10-08 08:52:452024-10-08 08:52:46

Judging History

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

  • [2024-10-08 08:52:46]
  • 评测
  • [2024-10-08 08:52:45]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long

struct team{
    int cnt,tim;
    vector<pair<int,int> >v[26];

    team():cnt(0),tim(0){
        for(int i=0;i<26;i++)v[i].clear();
    }

    inline int insert(int op,int tim,int flag){
        v[op].push_back({tim,flag});
        return v[op].size()-1;
    }

    inline void cal(int x=-1,int y=-1){
        cnt=tim=0;

        for(int i=0;i<26;i++){
            int sub=0,n=v[i].size();

            for(int j=0;j<n;j++){
                auto [T,f]=v[i][j];

                if(x==i&&y==j)f^=1;

                if(f){
                    cnt++;
                    tim+=T+sub*20;
                    break;
                }

                sub++;
            }
        }
    }

    inline bool empty()const{
        for(int i=0;i<26;i++){
            if(v[i].size())return false;
        }

        return (cnt==0)&&(tim==0);
    }

    inline bool legal()const{
        return cnt>0;
    }
};

struct judge{
    int cnt,tim,id;

    bool operator<(const judge &t)const{
        if(cnt==t.cnt)return tim<t.tim;
        return cnt>t.cnt;
    }
};

int m;

string s;
char ch;
int id,op,tim,flag;

inline void solve(){
    cin>>m;

    int cnt=0;
    map<string,int>mp;
    vector<string>name(1);

    vector<team>a(1);
    vector<array<int,3> >v(m);

    for(int i=0;i<m;i++){
        cin>>s>>ch>>tim;

        if(mp.find(s)==mp.end()){
            mp[s]=++cnt;
            a.push_back({});

            assert(a[cnt].empty());

            name.push_back(s);
        }

        id=mp[s],op=ch-'A';

        assert(0<=op&&op<26);

        cin>>s;

        assert(s[0]=='a'||s[0]=='r');

        v[i]={id,op,a[id].insert(op,tim,(s[0]=='a'?1:0))};
    }

    assert(a.size()-1==cnt);
    assert(a.size()==name.size());

    for(int i=1;i<=cnt;i++)a[i].cal();

    int sol=0;
    multiset<judge>s;

    auto del=[&](int i)->void {
        s.extract({a[i].cnt,a[i].tim,i});
        if(a[i].legal())sol--;
    };

    auto add=[&](int i)->void {
        s.insert({a[i].cnt,a[i].tim,i});
        if(a[i].legal())sol++;
    };

    for(int i=1;i<=cnt;i++)add(i);

    vector<int>ans(cnt+1);

    auto check=[&]()->void {
        assert(s.size()==cnt);
        assert(sol<=cnt);

        int line=min((sol+9)/10,35);

        assert(0<=line&&line<=35);

        int lst_cnt=-1,lst_tim=-1,num=0;

        for(const auto &[cnt,tim,id]:s){
            if(cnt==lst_cnt&&tim==lst_tim){
                ans[id]=1;
                num++;
            }else{
                if(num>=line)break;

                num++;
                ans[id]=1;
                lst_cnt=cnt,lst_tim=tim;
            }
        }
    };

    check();

    for(const auto &[i,op,j]:v){
        del(i);
        a[i].cal(op,j);
        add(i);
        
        check();
        
        del(i);
        a[i].cal();
        add(i);
    }

    cout<<accumulate(ans.begin(),ans.end(),0)<<"\n";

    for(int i=1;i<=cnt;i++){
        if(ans[i])cout<<name[i]<<" ";
    }

    cout<<"\n";
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t=1;
    cin>>t;
    while(t--)solve();

    return 0;
}

Details

answer.code: In lambda function:
answer.code:127:21: error: no matching function for call to ‘min(long long int, int)’
  127 |         int line=min((sol+9)/10,35);
      |                  ~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from answer.code:1:
/usr/include/c++/13/bits/stl_algobase.h:233:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)’
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
answer.code:127:21: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’)
  127 |         int line=min((sol+9)/10,35);
      |                  ~~~^~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)’
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note:   template argument deduction/substitution failed:
answer.code:127:21: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’)
  127 |         int line=min((sol+9)/10,35);
      |                  ~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5775:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)’
 5775 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5775:5: note:   template argument deduction/substitution failed:
answer.code:127:21: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’
  127 |         int line=min((sol+9)/10,35);
      |                  ~~~^~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)’
 5785 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note:   template argument deduction/substitution failed:
answer.code:127:21: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’
  127 |         int line=min((sol+9)/10,35);
      |                  ~~~^~~~~~~~~~~~~~~