답안 #502385

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
502385 2022-01-05T21:01:36 Z inksamurai Birmingham (COCI20_birmingham) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define crep(i,x,n) for(int i=x;i<n;i++)
#define drep(i,n) for(int i=n-1;i>=0;i--)
#define vec(...) vector<__VA_ARGS__>
#define _3qplfh5 ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;

void print(){
	cout<<"\n";
}
template<class te,class ...ti>
void print(const te&v, const ti&...nv) { 
	cout<<v;
	if(sizeof...(nv)){
		cout<<" ";
		print(nv...);
	}
}

using pii=pair<int,int>;
using vi=vector<int>;
using vll=vector<long long>;

const int inf=1e9;

void slv(){
	int n,m,q,k;
	cin>>n>>m>>q>>k;
	vi rbe(n,0);
	rep(_,q){
		int x;
		cin>>x;
		x--;
		rbe[x]=1;
	}
	vec(vi) adj(n);
	rep(i,m){
		int u,v;
		cin>>u>>v;
		u--,v--;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	priority_queue<pii,vec(pii),greater<pii>> pq;
	vi dp(n,inf);
	rep(v,n){
		if(rbe[v]){
			pq.push({0,v});
			dp[v]=0;
		}
	}
	while(sz(pq)){
		pii top=pq.top();
		pq.pop();
		int v=top.se,cost=top.fi;
		if(dp[v]!=cost) continue;
		for(auto u : adj[v]){
			if(dp[u]>cost+1){
				dp[u]=cost+1;
				pq.push({cost+1,u});
			}
		}
	}
	rep(v,n){
		ll ans=sqrt((dp[v]*2)/k);
		while(ans*(ans+1)*(ll)k<2ll*(ll)dp[v]) ans++;
		while((ans-1)*ans*(ll)k>=2ll*(ll)dp[v]) ans--;
		print(max(0,ans),"");
	}
	print('\n');
}

int main(){
_3qplfh5;
	int t=1;
	// cin>>t;
	rep(cs,t)
		slv();
//	
	return 0;
}

Compilation message

birmingham.cpp: In function 'void slv()':
birmingham.cpp:76:18: error: no matching function for call to 'max(int, ll&)'
   76 |   print(max(0,ans),"");
      |                  ^
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 birmingham.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:
birmingham.cpp:76:18: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   76 |   print(max(0,ans),"");
      |                  ^
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 birmingham.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:
birmingham.cpp:76:18: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   76 |   print(max(0,ans),"");
      |                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from birmingham.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:
birmingham.cpp:76:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   76 |   print(max(0,ans),"");
      |                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from birmingham.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:
birmingham.cpp:76:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   76 |   print(max(0,ans),"");
      |                  ^