Submission #868549

#TimeUsernameProblemLanguageResultExecution timeMemory
868549lolismekBitaro’s Party (JOI18_bitaro)C++14
Compilation error
0 ms0 KiB
#include <algorithm>
#include <iostream>
#include <vector>

#define pii pair <int, int>

using namespace std;

const int NMAX = 100000;
const int B = 317;

vector <int> adj[NMAX + 1];
vector <pii> t[NMAX + 1];

int from[NMAX + 1];
int dist[NMAX + 1];

bool no[NMAX + 1];

int main(){

    int n, m, q;
    cin >> n >> m >> q;

    for(int i = 1; i <= m; i++){
        int a, b;
        cin >> a >> b;
        adj[b].push_back(a);
    }

    for(int i = 1; i <= n; i++){
        vector <int> curr;
        for(int vec : adj[i]){
            for(pii x : t[vec]){
                if(from[x.second] == i){
                    dist[x.second] = max(dist[x.second], x.first + 1);
                }else{
                    from[x.second] = i;
                    dist[x.second] = x.first + 1;
                    curr.push_back(x.second);
                }
            }
        }

        t[i].push_back({0, i});
        for(int x : curr){
            t[i].push_back({dist[x], x});
        }
        sort(t[i].begin(), t[i].end(), greater <pii>());
        if((int)t[i].size() > B){
            t[i].erase(t[i].begin() + B, t[i].end());
        }
    }

    while(q--){
        int node, nr;
        cin >> node >> nr;

        vector <int> bad;
        for(int i = 1; i <= nr; i++){
            int x;
            cin >> x;
            bad.push_back(x);
            no[x] = true;
        }

        int ans = -1;
        if((int)bad.size() > B){
            vector <int> dp(n + 1, -1);

            dp[node] = 0;
            for(int i = node; i >= 1; i--){
                if(dp[i] != -1){
                    if(i != bad){
                        ans = max(ans, dp[i]);
                    }
                    for(int vec : adj[i]){
                        dp[vec] = max(dp[vec], dp[i] + 1);
                    }
                }
            }
        }else{
            for(pii x : t[node]){
                if(!no[x.second]){
                    ans = x.first;
                    break;
                }
            }
        }

        cout << ans << '\n';

        for(int x : bad){
            no[x] = false;
        }
    }

    return 0;
}

/*
5 6 3
1 2
2 4
3 4
1 3
3 5
4 5
4 1 1
5 2 2 3
2 3 1 4 5
*/

Compilation message (stderr)

bitaro.cpp: In function 'int main()':
bitaro.cpp:74:26: error: no match for 'operator!=' (operand types are 'int' and 'std::vector<int>')
   74 |                     if(i != bad){
      |                        ~ ^~ ~~~
      |                        |    |
      |                        int  std::vector<int>
In file included from /usr/include/c++/10/utility:70,
                 from /usr/include/c++/10/algorithm:60,
                 from bitaro.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:496:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator!=(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)'
  496 |     operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
      |     ^~~~~~~~
/usr/include/c++/10/bits/stl_pair.h:496:5: note:   template argument deduction/substitution failed:
bitaro.cpp:74:29: note:   mismatched types 'const std::pair<_T1, _T2>' and 'int'
   74 |                     if(i != bad){
      |                             ^~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:67,
                 from /usr/include/c++/10/algorithm:61,
                 from bitaro.cpp:1:
/usr/include/c++/10/bits/stl_iterator.h:372:5: note: candidate: 'template<class _Iterator> bool std::operator!=(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)'
  372 |     operator!=(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/10/bits/stl_iterator.h:372:5: note:   template argument deduction/substitution failed:
bitaro.cpp:74:29: note:   mismatched types 'const std::reverse_iterator<_Iterator>' and 'int'
   74 |                     if(i != bad){
      |                             ^~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:67,
                 from /usr/include/c++/10/algorithm:61,
                 from bitaro.cpp:1:
/usr/include/c++/10/bits/stl_iterator.h:410:5: note: candidate: 'template<class _IteratorL, class _IteratorR> bool std::operator!=(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&)'
  410 |     operator!=(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/10/bits/stl_iterator.h:410:5: note:   template argument deduction/substitution failed:
bitaro.cpp:74:29: note:   mismatched types 'const std::reverse_iterator<_Iterator>' and 'int'
   74 |                     if(i != bad){
      |                             ^~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:67,
                 from /usr/include/c++/10/algorithm:61,
                 from bitaro.cpp:1:
/usr/include/c++/10/bits/stl_iterator.h:1444:5: note: candidate: 'template<class _IteratorL, class _IteratorR> bool std::operator!=(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorR>&)'
 1444 |     operator!=(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/10/bits/stl_iterator.h:1444:5: note:   template argument deduction/substitution failed:
bitaro.cpp:74:29: note:   mismatched types 'const std::move_iterator<_IteratorL>' and 'int'
   74 |                     if(i != bad){
      |                             ^~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:67,
                 from /usr/include/c++/10/algorithm:61,
                 from bitaro.cpp:1:
/usr/include/c++/10/bits/stl_iterator.h:1501:5: note: candidate: 'template<class _Iterator> bool std::operator!=(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorL>&)'
 1501 |     operator!=(const move_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/10/bits/stl_iterator.h:1501:5: note:   template argument deduction/substitution failed:
bitaro.cpp:74:29: note:   mismatched types 'const std::move_iterator<_IteratorL>' and 'int'
   74 |                     if(i != bad){
      |                             ^~~
In file included from /usr/include/c++/10/iosfwd:40,
                 from /usr/include/c++/10/ios:38,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from bitaro.cpp:2:
/usr/include/c++/10/bits/postypes.h:227:5: note: candidate: 'template<class _StateT> bool std::operator!=(const std::fpos<_StateT>&, const std::fpos<_StateT>&)'
  227 |     operator!=(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/10/bits/postypes.h:227:5: note:   template argument deduction/substitution failed:
bitaro.cpp:74:29: note:   mismatched types 'const std::fpos<_StateT>' and 'int'
   74 |                     if(i != bad){
      |                             ^~~
In file included from /usr/include/c++/10/string:41,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from bitaro.cpp:2:
/usr/include/c++/10/bits/allocator.h:213:5: note: candidate: 'template<class _T1, class _T2> bool std::operator!=(const std::allocator<_CharT>&, const std::allocator<_T2>&)'
  213 |     operator!=(const allocator<_T1>&, const allocator<_T2>&)
      |     ^~~~~~~~
/usr/include/c++/10/bits/allocator.h:213:5: note:   template argument deduction/substitution failed:
bitaro.cpp:74:29: note:   mismatched types 'const std::allocator<_CharT>' and 'int'
   74 |                     if(i != bad){
      |                             ^~~
In file included from /usr/include/c++/10/string:55,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from bitaro.cpp:2:
/usr/include/c++/10/bits/basic_string.h:6229:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)'
 6229 |     operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6229:5: note:   template argument deduction/substitution failed:
bitaro.cpp:74:29: note:   mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'int'
   74 |                     if(i != bad){
      |                             ^~~
In file included from /usr/include/c++/10/string:55,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from bitaro.cpp:2:
/usr/include/c++/10/bits/basic_string.h:6242:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const _CharT*, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)'
 6242 |     operator!=(const _CharT* __lhs,
      |     ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6242:5: note:   template argument deduction/substitution failed:
bitaro.cpp:74:29: note:   mismatched types 'const _CharT*' and 'int'
   74 |                     if(i != bad){
      |                             ^~~
In file included from /usr/include/c++/10/string:55,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from bitaro.cpp:2:
/usr/include/c++/10/bits/basic_string.h:6254:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)'
 6254 |     operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6254:5: note:   template argument deduction/substitution failed:
bitaro.cpp:74:29: note:   mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'int'
   74 |                     if(i != bad){
      |                             ^~~
In file included from /usr/include/c++/10/bits/ios_base.h:46,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from bitaro.cpp:2:
/usr/include/c++/10/system_error:398:3: note: candidate: 'bool std::operator!=(const std::error_code&, const std::error_code&)'
  398 |   operator!=(const error_code& __lhs, const error_code& __rhs) noexcept
      |   ^~~~~~~~
/usr/include/c++/10/system_error:398:32: note:   no known conversion for argument 1 from 'int' to 'const std::error_code&'
  398 |   operator!=(const error_code& __lhs, const error_code& __rhs) noexcept
      |              ~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/10/system_error:404:3: note: candidate: 'bool std::operator!=(const std::error_code&, const std::error_condition&)'
  404 |   operator!=(const error_code& __lhs, const error_condition& __rhs) noexcept
      |   ^~~~~~~~
/usr/include/c++/10/system_error:404:32: note:   no known conversion for argument 1 from 'int' to 'const std::error_code&'
  404 |   operator!=(const error_code& __lhs, const error_condition& __rhs) noexcept
      |              ~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/10/system_error:410:3: note: candidate: 'bool std::operator!=(const std::error_condition&, const std::error_code&)'
  410 |   operator!=(const error_condition& __lhs, const error_code& __rhs) noexcept
      |   ^~~~~~~~
/usr/include/c++/10/system_error:410:37: note:   no known conversion for argument 1 from 'int' to 'const std::error_condition&'
  410 |   operator!=(const error_condition& __lhs, const error_code& __rhs) noexcept
      |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/10/system_error:415:3: note: candidate: 'bool std::operator!=(const std::error_condition&, const std::error_condition&)'
  415 |   operator!=(const error_condition& __lhs,
      |   ^~~~~~~~
/usr/include/c++/10/system_error:415:37: note:   no known conversion for argument 1 from 'int' to 'const std::error_condition&'
  415 |   operator!=(const error_condition& __lhs,
      |              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
In file included from /usr/include/c++/10/bits/locale_facets.h:48,
                 from /usr/include/c++/10/bits/basic_ios.h:37,
                 from /usr/include/c++/10/ios:44,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from bitaro.cpp:2:
/usr/include/c++/10/bits/streambuf_iterator.h:233:5: note: candidate: 'template<class _CharT, class _Traits> bool std::operator!=(const std::istreambuf_iterator<_CharT, _Traits>&, const std::istreambuf_iterator<_CharT, _Traits>&)'
  233 |     operator!=(const istreambuf_iterator<_CharT, _Traits>& __a,
      |     ^~~~~~~~
/usr/include/c++/10/bits/streambuf_iterator.h:233:5: note:   template argument deduction/substitution failed:
bitaro.cpp:74:29: note:   mismatched types 'const std::istreambuf_iterator<_CharT, _Traits>' and 'int'
   74 |                     if(i != bad){
      |                             ^~~
In file included from /usr/include/c++/10/vector:67,
                 from bitaro.cpp:3:
/usr/include/c++/10/bits/stl_vector.h:1937:5: note: candidate: 'template<class _Tp, class _Alloc> bool std::operator!=(const std::vector<_Tp, _Alloc>&, const std::vector<_Tp, _Alloc>&)'
 1937 |     operator!=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
      |     ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1937:5: note:   template argument deduction/substitution failed:
bitaro.cpp:74:29: note:   mismatched types 'const std::vector<_Tp, _Alloc>' and 'int'
   74 |                     if(i != bad){
      |                             ^~~
In file included from /usr/include/c++/10/string:41,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from bitaro.cpp:2:
/usr/include/c++/10/bits/allocator.h:197:7: note: candidate: 'bool std::operator!=(const std::allocator<int>&, const std::allocator<int>&)'
  197 |       operator!=(const allocator&, const allocator&) _GLIBCXX_NOTHROW
      |       ^~~~~~~~
/usr/include/c++/10/bits/allocator.h:197:18: note:   no known conversion for argument 1 from 'int' to 'const std::allocator<int>&'
  197 |       operator!=(const allocator&, const allocator&) _GLIBCXX_NOTHROW
      |                  ^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:67,
                 from /usr/include/c++/10/algorithm:61,
                 from bitaro.cpp:1:
/usr/include/c++/10/bits/stl_iterator.h:1080:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator!=(const __gnu_cxx::__normal_iterator<_IteratorL, _Container>&, const __gnu_cxx::__normal_iterator<_IteratorR, _Container>&)'
 1080 |     operator!=(const __normal_iterator<_IteratorL, _Container>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/10/bits/stl_iterator.h:1080:5: note:   template argument deduction/substitution failed:
bitaro.cpp:74:29: note:   mismatched types 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' and 'int'
   74 |                     if(i != bad){
      |                             ^~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:67,
                 from /usr/include/c++/10/algorithm:61,
                 from bitaro.cpp:1:
/usr/include/c++/10/bits/stl_iterator.h:1088:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator!=(const __gnu_cxx::__normal_iterator<_Iterator, _Container>&, const __gnu_cxx::__normal_iterator<_Iterator, _Container>&)'
 1088 |     operator!=(const __normal_iterator<_Iterator, _Container>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/10/bits/stl_iterator.h:1088:5: note:   template argument deduction/substitution failed:
bitaro.cpp:74:29: note:   mismatched types 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' and 'int'
   74 |                     if(i != bad){
      |                             ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/c++allocator.h:33,
                 from /usr/include/c++/10/bits/allocator.h:46,
                 from /usr/include/c++/10/string:41,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from bitaro.cpp:2:
/usr/include/c++/10/ext/new_allocator.h:178:2: note: candidate: 'template<class _Up> bool __gnu_cxx::operator!=(const __gnu_cxx::new_allocator<int>&, const __gnu_cxx::new_allocator<_Tp>&)'
  178 |  operator!=(const new_allocator&, const new_allocator<_Up>&)
      |  ^~~~~~~~
/usr/include/c++/10/ext/new_allocator.h:178:2: note:   template argument deduction/substitution failed:
bitaro.cpp:74:29: note:   'std::vector<int>' is not derived from 'const __gnu_cxx::new_allocator<_Tp>'
   74 |                     if(i != bad){
      |                             ^~~