Submission #260394

#TimeUsernameProblemLanguageResultExecution timeMemory
260394aggu_01000101The Big Prize (IOI17_prize)C++14
Compilation error
0 ms0 KiB
#include <iostream>
#include "prize.h"
#include <assert.h>
#include <algorithm>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <bits/stdc++.h>
#define initrand mt19937 mt_rand(time(0));
#define rand mt_rand()
#define int long long
#define INF 10000000000000000
#define MOD 1000000007
using namespace std;
initrand;
/*vector<int> ask(int x){
    cout<<"QUERY AT "<<x<<endl;
    vector<int> tr = {0, 0};
    cin>>tr[0]>>tr[1];
    return tr;
}*/
int get(int l, int r){
    return (((rand%(r-l+1))) + l);
}
signed find_best(signed n){
    vector<int> v;
    for(int i =1 ;i<=n;i++) v.push_back(i);
    bool found = false;
    map<int, int> first;
    map<int, int> last;
    int ans = -1;
    while(!found){
        int tq = get(0, v.size() - 1);
        signed ta = v[tq]; //we will ask this
        vector<signed> qq = ask(ta-1);
        if(qq[0] == qq[1] && qq[1]==0){
            ans = ta;
            found = true;
            continue;
        }
        if(first[qq[0]] != 0){
            auto it = upper_bound(v.begin(), v.end(), first[qq[0]]);
            auto it1 = lower_bound(v.begin(), v.end(), ta);
            v.erase(it, it1);
            first[qq[0]] = min(first[qq[0]], ta);
        }
        else first[qq[0]] = ta;
        if(last[qq[1]] != 0){
            auto it = lower_bound(v.begin(), v.end(), ta);
            auto it1 = lower_bound(v.begin(), v.end(), last[qq[1]]);
            v.erase(it, it1);
            last[qq[1]] = max(last[qq[1]], ta);
        }
        else last[qq[1]] = ta;
        auto it = lower_bound(v.begin(), v.end(), ta);
        while((*it) == ta) {
            //cout << "We should be erasing " << (*it) << endl;
            v.erase(it);
            it = lower_bound(v.begin(), v.end(), ta);
        }
        /*cout<<"Remaining array: "<<endl;
        for(int j: v){
            cout<<j<<" ";
        }
        cout<<endl;*/
    }
    return (ans-1);
}
/*signed main(){
    signed n;
    cin>>n;
    int ans = find_best(n);
    cout<<"Final answer: "<<ans<<endl;
}*/
/*
11 12
0 1 3
0 2 4
2 3 5
3 4 4
4 5 6
0 6 3
6 7 2
6 8 5
8 9 6
8 10 7
 */
/*
3 3
0 1 1
1 2 1
 */

Compilation message (stderr)

prize.cpp: In function 'int find_best(int)':
prize.cpp:47:48: error: no matching function for call to 'min(std::map<long long int, long long int>::mapped_type&, int&)'
             first[qq[0]] = min(first[qq[0]], ta);
                                                ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from prize.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
prize.cpp:47:48: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
             first[qq[0]] = min(first[qq[0]], ta);
                                                ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from prize.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
prize.cpp:47:48: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
             first[qq[0]] = min(first[qq[0]], ta);
                                                ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from prize.cpp:4:
/usr/include/c++/7/bits/stl_algo.h:3450:5: note: candidate: template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)
     min(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
prize.cpp:47:48: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
             first[qq[0]] = min(first[qq[0]], ta);
                                                ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from prize.cpp:4:
/usr/include/c++/7/bits/stl_algo.h:3456:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
prize.cpp:47:48: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
             first[qq[0]] = min(first[qq[0]], ta);
                                                ^
prize.cpp:54:46: error: no matching function for call to 'max(std::map<long long int, long long int>::mapped_type&, int&)'
             last[qq[1]] = max(last[qq[1]], ta);
                                              ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from prize.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
prize.cpp:54:46: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
             last[qq[1]] = max(last[qq[1]], ta);
                                              ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from prize.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
prize.cpp:54:46: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
             last[qq[1]] = max(last[qq[1]], ta);
                                              ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from prize.cpp:4:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
prize.cpp:54:46: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
             last[qq[1]] = max(last[qq[1]], ta);
                                              ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from prize.cpp:4:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
prize.cpp:54:46: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
             last[qq[1]] = max(last[qq[1]], ta);
                                              ^