Submission #854943

#TimeUsernameProblemLanguageResultExecution timeMemory
854943parlimoosBitaro’s Party (JOI18_bitaro)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;

const int root = 320;

int n , m , q , r;
vector<int> g[100000];
vector<pair<int , int>> lps[100000];
int dels[100000];
int dis[100000];
int ddd[100000][2];

void init(){
	for(int i = 0 ; i < n ; i++){
		vector<int> exs;
		lps[i].push_back({0 , i});
		exs.push_back(i);
		ddd[i][0] = 0;
		ddd[i][1] = i + 1;
		
		for(int v : g[i]){
			for(pair<int , int> el : lps[v]){
				if(ddd[el.second][1] != i + 1){
					exs.push_back(el.second);
					ddd[el.second][1] = i + 1;
					ddd[el.second][0] = el.first + 1;
				}else ddd[el.second][0] = max(ddd[el.second] , el.first + 1);
			}
		}
		for(int v : g[i]){
			for(int el : exs){
				lps[i].push_back({ddd[el][0] , el});
			}
			sort(lps[i].begin() , lps[i].end() , [](pair<int , int> a , pair<int , int>b){
				return (a.first > b.first);
			});
			
			int len = (int)lps[i].size();
			while(len > root){
				lps[i].pop_back();
				len--;
			}
		}
	}
}
void bfs(int op){
	fill(&dis[0] , &dis[100000] , 0);
	for(int i = 0 ; i <= r ; i++){
		for(int u : g[i]){
			dis[i] = max(dis[u] + 1 , dis[i]);
		}
		if(dis[i] == 0 and dels[i] == op){
			dis[i] = -1;
		}
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n >> m >> q;
	for(int i = 0 ; i < m ; i++){
		int v , u;
		cin >> v >> u;
		v-- , u--;
		g[u].push_back(v);
	}
	
	if(q > 1) init();
	for(int i = 0 ; i < q ; i++){
		int y;
		cin >> r >> y;
		r--;
		
		for(int j = 0 ; j < y ; j++){
			int d;
			cin >> d;
			d--;
			dels[d] = i + 1;
		}
		if(y >= root or q == 1){
			bfs(i + 1);
			cout << dis[r] << "\n";
		}else{
			int res = -1;
			for(int j = 0 ; j < (int)lps[r].size() ; j++){
				if(dels[lps[r][j].second] != i + 1){
					res = lps[r][j].first;
					break;
				}
			}
			cout << res << "\n";
		}
	}
}

Compilation message (stderr)

bitaro.cpp: In function 'void init()':
bitaro.cpp:27:64: error: no matching function for call to 'max(int [2], int)'
   27 |     }else ddd[el.second][0] = max(ddd[el.second] , el.first + 1);
      |                                                                ^
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:27:64: note:   deduced conflicting types for parameter 'const _Tp' ('int [2]' and 'int')
   27 |     }else ddd[el.second][0] = max(ddd[el.second] , el.first + 1);
      |                                                                ^
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:27:64: note:   deduced conflicting types for parameter 'const _Tp' ('int [2]' and 'int')
   27 |     }else ddd[el.second][0] = max(ddd[el.second] , el.first + 1);
      |                                                                ^
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:27:64: note:   mismatched types 'std::initializer_list<_Tp>' and 'int*'
   27 |     }else ddd[el.second][0] = max(ddd[el.second] , el.first + 1);
      |                                                                ^
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:27:64: note:   mismatched types 'std::initializer_list<_Tp>' and 'int*'
   27 |     }else ddd[el.second][0] = max(ddd[el.second] , el.first + 1);
      |                                                                ^
bitaro.cpp:30:11: warning: unused variable 'v' [-Wunused-variable]
   30 |   for(int v : g[i]){
      |           ^