Submission #944010

#TimeUsernameProblemLanguageResultExecution timeMemory
944010RadicaIBitaro’s Party (JOI18_bitaro)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#define pi pair<int,int>
#define pb push_back
#define V vector
#define vi V<int>
#define mi map<int,int>
#define MOD 1000000007
#define MOD2 998244353
#define mp make_pair
#define ins insert
#define qi queue<int>
#define pqi priority_queue<int>
#define si set<int>
#define v2i V<vi>
#define v3i V<v2i>
#define v4i V<v3i>
#define v5i V<v4i>
#define INF 1e18
#define all(x) begin(x), end(x)
#define sz(x) (int) (x).size()
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define print(x) cout << x<<" ";
#define vpi V<pi>
#define Y cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define msi multiset<int>
#define F first
#define S second
#define ld long double
#define RE return;
#define IMP cout<<-1<<endl;return;
using namespace std;

template <typename T>
std::istream& operator>>(std::istream& in, std::vector<T>& vec) {
    for (T& x : vec) {
        in >> x;
    }
    return in;
}

const int block = 350;

 
signed main(){
	fastio;
	int n,m,q; cin>>n>>m>>q;
	v2i adj(n); 
	for(int i=0; i<m; i++){
		int s,e; cin>>s>>e; s--;e--;
		adj[e].pb(s);
	}
	V<set<pi>> mx(n); 
	for(int i=0; i<n; i++){
		mx[i].ins({0,i});
		map<int,si> jhxt;
		for(auto &x: adj[i]){
			for(auto &y: mx[x]){
				jhxt[y.S].ins(y.F+1);
			}
		}
		for(auto &x: jhxt){
			mx[i].ins({*x.S.rbegin(), x.F}); 
			if(sz(mx[i])>block) mx[i].erase(mx[i].begin());
		}
	}
	vi store(n, q+1);
	while(q--){
		int t,y; cin >> t>>y; 
		t--; 
		for(int i=0; i<y; i++){int x; cin >> x; store[x-1]=q;}
		if(y>=block){
			vi dp(t+1,-1);
			for(int i=0; i<=t; i++){
				if(store[i]!=q)dp[i]=max(dp[i],0ll);
				for(auto &x: adj[i]){
					if(dp[x]!=-1)dp[i] = max(dp[x]+1, dp[i]);
				}
			}
			cout << dp[t]<<endl;
		}else{
			int ans = -1;
			for(auto &x: mx[t])if(store[x.S]!=q) ans = x.F;
			cout<<ans<<endl;
		}
	}
}

Compilation message (stderr)

bitaro.cpp: In function 'int main()':
bitaro.cpp:78:39: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&, long long int)'
   78 |     if(store[i]!=q)dp[i]=max(dp[i],0ll);
      |                                       ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from bitaro.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:
bitaro.cpp:78:39: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   78 |     if(store[i]!=q)dp[i]=max(dp[i],0ll);
      |                                       ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from bitaro.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:
bitaro.cpp:78:39: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   78 |     if(store[i]!=q)dp[i]=max(dp[i],0ll);
      |                                       ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from bitaro.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:
bitaro.cpp:78:39: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   78 |     if(store[i]!=q)dp[i]=max(dp[i],0ll);
      |                                       ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from bitaro.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:
bitaro.cpp:78:39: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   78 |     if(store[i]!=q)dp[i]=max(dp[i],0ll);
      |                                       ^