Submission #1285007

#TimeUsernameProblemLanguageResultExecution timeMemory
1285007beka19Pairs (IOI07_pairs)C++20
Compilation error
0 ms0 KiB
    #include <bits/stdc++.h>
using namespace std;
#define sped ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define s second
#define f first
#define int long long
const int N = 1e6 + 1;
int t[N*36],L[N * 36],R[N * 36];
int z[N * 36];
int cntv = 2;
void update(int v,int tl,int tr,int pos){
   if(tl == tr){
        t[v]++;
   }
   else{
     int tm = (tl + tr) / 2;
     if(pos <= tm){
     if(L[v] == 0) L[v] = cntv++;
     update(L[v],tl,tm,pos);
     }
     else{
     if(R[v] == 0) R[v] = cntv++;
     update(R[v],tm+1,tr,pos);
     }
     t[v] = t[L[v]] + t[R[v]];
   }
}
int get(int v,int tl,int tr,int l,int r){
    if(l > r) return 0;
  if(t[v] == 0) return 0;
  if(tl > r || l > tr) return 0;
   if(tl >= l && tr <= r){
       return t[v];
   }
   int tm = (tl + tr) / 2;
   return get(L[v] ,tl,tm,l,r) + get(R[v] ,tm+1,tr,l,r);
}
void okok(){
    int bb;
    cin >> bb;
    int n;
    cin >> n;
    int d;
    cin >> d;
    int m;
    cin >> m;
    if(bb == 1){
        int NN = 1e9;
        int a[n + 1];
        map<int,int>mm;
        for(int i =1;i <= n;i++){
            cin >> a[i];
            mm[a[i]]++;
            update(1,1,NN,a[i]);
        }
        int ans = 0;
        for(int i = 1;i <= n;i++){
            ans += get(1,1,NN,max(1,a[i] - d),a[i]-1);
            ans += get(1,1,NN,a[i] + 1,min(a[i] + d,NN));
            ans += mm[a[i]] - 1;
        }
        cout << ans / 2;
        return;

    }
    int a[n + 1];
    int b[n + 1];
    int c[n + 1];
    for(int i = 1;i <= n;i++){
        cin >> a[i];
        if(bb >= 2){
            cin >> b[i];
        }
        if(bb == 3){
            cin >> c[i];
        }
    }
    int cc = 0;
    for(int i = 1;i <= n;i++){
        for(int j = i + 1;j <= n;j++){
                int ans = 0;
            ans += abs(a[i] - a[j]);
            if(bb >= 2){
                ans += abs(b[i] - b[j]);
             }
            if(bb == 3){
                ans += abs(c[i] - c[j]);
            }
            if(ans <= d)cc++;

        }
    }
    cout << cc;
}
signed main() {
//freopen("bank.in", "r", stdin) ;
//freopen("bansk.out", "w", stdout);
sped
int tt = 1;
//cin >> tt;
while(tt--){
    okok();
    //cout << '\n';
    }
}

Compilation message (stderr)

pairs.cpp: In function 'void okok()':
pairs.cpp:59:34: error: no matching function for call to 'max(int, long long int)'
   59 |             ans += get(1,1,NN,max(1,a[i] - d),a[i]-1);
      |                               ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from pairs.cpp: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:
pairs.cpp:59:34: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   59 |             ans += get(1,1,NN,max(1,a[i] - d),a[i]-1);
      |                               ~~~^~~~~~~~~~~~
/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:
pairs.cpp:59:34: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   59 |             ans += get(1,1,NN,max(1,a[i] - d),a[i]-1);
      |                               ~~~^~~~~~~~~~~~
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:
pairs.cpp:59:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   59 |             ans += get(1,1,NN,max(1,a[i] - d),a[i]-1);
      |                               ~~~^~~~~~~~~~~~
/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:
pairs.cpp:59:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   59 |             ans += get(1,1,NN,max(1,a[i] - d),a[i]-1);
      |                               ~~~^~~~~~~~~~~~