QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#720278#9544. Grand Prix of BallanceehdxbcCompile Error//C++201.4kb2024-11-07 11:33:202024-11-07 11:33:21

Judging History

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

  • [2024-11-07 11:33:21]
  • 评测
  • [2024-11-07 11:33:20]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
struct node {
    int id, sum;
};
void solve() {
	int n, m, q;
    cin >> n >> m >> q;
    vector<node> a(m + 1);
    for (int i = 1; i <= m; i++) {
        a[i].id = i;
    }
    vector<bool> vis(n + 1);
    int now = 0, cnt = m;
    set<int> st;
    while (q--) {
        int op, i, x;
        cin >> op;
        if (op == 1) {
            cin >> x;
            if (!vis[x] && x <= n) {
                now = x;
                vis[x] = true;
                st.clear();
            }                
            else now = -1;
            cnt = m;
        } else if (op == 2){
            cin >> i >> x;
            if (st.find(i) == st.end() && x == now) {
                a[i].sum += cnt;
                cnt = max(cnt - 1, 0);
                st.insert(i);
            }
        } else {
            cin >> i >> x;
            if (x == now)
                st.insert(i);
        }    
    } 
    sort(a.begin() + 1, a.end(), [&](node &x, node &y) {
       return x.sum != y.sum ? x.sum > y.sum : x.id < y.id; 
    });
    for (int i = 1; i <= m; i++) {
        cout << a[i].id << " " << a[i].sum << endl;
    }
}
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int t = 1;
	cin >> t;
	while (t--) {
		solve();
	}
}

Details

answer.code: In function ‘void solve()’:
answer.code:34:26: error: no matching function for call to ‘max(long long int, int)’
   34 |                 cnt = max(cnt - 1, 0);
      |                       ~~~^~~~~~~~~~~~
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:257:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)’
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
answer.code:34:26: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’)
   34 |                 cnt = max(cnt - 1, 0);
      |                       ~~~^~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note:   template argument deduction/substitution failed:
answer.code:34:26: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’)
   34 |                 cnt = max(cnt - 1, 0);
      |                       ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)’
 5795 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note:   template argument deduction/substitution failed:
answer.code:34:26: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’
   34 |                 cnt = max(cnt - 1, 0);
      |                       ~~~^~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)’
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note:   template argument deduction/substitution failed:
answer.code:34:26: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’
   34 |                 cnt = max(cnt - 1, 0);
      |                       ~~~^~~~~~~~~~~~