Submission #1002611

# Submission time Handle Problem Language Result Execution time Memory
1002611 2024-06-19T17:00:47 Z codexistent Gondola (IOI14_gondola) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include <gondola.h>
using namespace std;
#define MOD 1000000009
#define ll long long
#define FOR(i, a, b) for(ll i = a; i <= b; i++)
 
int diff(int n, int a, int b){
    if(b >= a) return b - a;
    else return (n - a) + b;
}
 
int valid(int n, int inputSeq[]){
    pair<int, int> prev = make_pair(-1, 0);
    set<int> s;
    FOR(i, 0, n - 1){
        if(inputSeq[i] <= n){
            if(prev.first == -1){
                prev = make_pair(i, inputSeq[i]);
            }else{
                if((((prev.second + diff(n, prev.first, i)) % n) == 0 ? n : ((prev.second + diff(n, prev.first, i)) % n)) != inputSeq[i]) return 0;
                prev = make_pair(i, inputSeq[i]);
            }
        }else{
            if(s.find(inputSeq[i]) != s.end()) return 0;
            s.insert(inputSeq[i]);
        }
    }
 
    return 1;
}
 
int replacement(int n, int gondolaSeq[], int replacementSeq[]){
    int idx = -1, mx = -1;
    vector<pair<int, int> > v;
    FOR(i, 0, n - 1){
        if(gondolaSeq[i] <= n){
            idx = gondolaSeq[i] - i;
            if(idx <= 0) idx += n;
        }else{
            v.push_back(make_pair(gondolaSeq[i], i));
        }
        mx = max(mx, gondolaSeq[i]);
    }
    sort(v.begin(), v.end());
 
    if(idx == -1) idx = 1;
 
    set<int> s;
    FOR(i, 0, (int)(v.size() - 2)) {
        s.insert(v[i].first);
        replacementSeq[v[i].first - n - 1] = ((idx + v[i].second) % n == 0) ? n : ((idx + v[i].second) % n);
    }
 
    if(v.size()){
        int prev = ((idx + v[v.size() - 1].second) % n == 0) ? n : ((idx + v[v.size() - 1].second) % n);
        FOR(i, n + 1, mx) {
            if(s.find(i) == s.end()) {
                replacementSeq[i - (n + 1)] = prev;
                prev = i;
            }
        }
    }
    return mx - n;
}
 
int countReplacement(int n, int inputSeq[]){
    if(!valid(n, inputSeq)) return 0;
    ll r = 1, c = 0, mx = -1;
    set<ll> s;
    bool fct = true;
    FOR(i, 0, n - 1){
        if(inputSeq[i] <= n) fct = false;
        else{
            c++, s.insert(inputSeq[i]);
        }
        mx = max(mx, inputSeq[i]);
    }
 
    ll c2 = 0;
    FOR(i, n + 1, mx){
        if(s.find(i) == s.end()){
            r = (r * (c - c2)) % MOD;
        }else{
            c2++;
        }
    }
    if(fct){
        FOR(i, 1, n) r = (r * (i)) % MOD;
    }
    return r;
}

Compilation message

gondola.cpp: In function 'int countReplacement(int, int*)':
gondola.cpp:77:33: error: no matching function for call to 'max(long long int&, int&)'
   77 |         mx = max(mx, inputSeq[i]);
      |                                 ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from gondola.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
gondola.cpp:77:33: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   77 |         mx = max(mx, inputSeq[i]);
      |                                 ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from gondola.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
gondola.cpp:77:33: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   77 |         mx = max(mx, inputSeq[i]);
      |                                 ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from gondola.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
gondola.cpp:77:33: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   77 |         mx = max(mx, inputSeq[i]);
      |                                 ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from gondola.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
gondola.cpp:77:33: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   77 |         mx = max(mx, inputSeq[i]);
      |                                 ^