답안 #587536

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
587536 2022-07-02T05:05:37 Z Tekor Team Contest (JOI22_team) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
void boos() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
const int N = 3e5 + 100;
const int M = 21;
const ll LLINF = (ll)1e18;
ll a[N],b[N],c[N];
bool u[M][M][M],u1[M][M][M],u2[M][M][M];
int n;
bool cmp(int x,int y) {
	return a[x] < a[y];
}
bool cmp1(int x,int y) {
	return b[x] < b[y];
}
ll check(ll x,ll y,ll t) {
	bool ch = 0,ch1 = 0,ch2 = 0;
	for(int i = 1;i <= n;i++) {
		if(a[i] == x && b[i] < y && c[i] < t)ch = 1;
		if(a[i] < x && b[i] == y && c[i] < t)ch1 = 1;
		if(a[i] < x && b[i] < y && c[i] == t)ch2 = 1;
	}
	if(ch && ch1 && ch2)return x + y + t;
	else return -1;
}
void solve() {
	cin >> n;
	vector <int> g,q;
	ll mx = 0;
	for(int i = 1;i <= n;i++) {
		cin >> a[i] >> b[i] >> c[i];
		mx = max(mx,a[i]);
		mx = max(mx,b[i]);
		mx = max(mx,c[i]);
		g.pb(i);
		q.pb(i);
	}
	ll ans = -1;
	if(mx <= 20) {
		for(int i = 1;i <= n;i++) {
			for(int j = b[i] + 1;j <= mx;j++) {
				for(int h = c[i] + 1;h <= mx;h++) {
					u[a[i]][j][h] = 1;
				}
			}
			for(int j = a[i] + 1;j <= mx;j++) {
				for(int h = c[i] + 1;h <= mx;h++) {
					u1[b[i]][j][h] = 1;
				}
			}
			for(int j = a[i] + 1;j <= mx;j++) {
				for(int h = b[i] + 1;h <= mx;h++) {
					u2[c[i]][j][h] = 1;
				}
			}
		}
		for(int i = 1;i <= mx;i++) {
			for(int j = 1;j <= mx;j++) {
				for(int h = 1;h <= mx;h++) {
					if(u[i][j][h] && u1[j][i][h] && u2[h][i][j])ans = max(ans,i + j + h);
				}
			}
		}
		cout << ans;
		return;
	}
	sort(all(g),cmp);
	sort(all(q),cmp1);
	for(auto v : g) {
		ll mxa = a[v];
		set <ll> tt;
		//cout << v << " -- " << a[v] << endl;
		for(int j = 0;j < q.size();j++) {
			int to = q[j];
			ll mxb = b[to];
			//cout << to << " :: " << b[to] << " == ";
			if(j > 0 && b[q[j - 1]] != b[to]) {
				int pos = j - 1;
				while(pos >= 0 && b[q[pos]] == b[q[j - 1]]) {
					int p = q[pos];
					if(a[p] < mxa)tt.insert(c[p]);
					pos--;
				}	
			}
			if(a[to] >= mxa || b[v] >= mxb) {
				//cout << "fail" << endl;
				continue;
			}
			if(!tt.empty()) {
				ll val = *(tt.rbegin());
				if(val > max(c[v],c[to]))ans = max(ans,mxa + mxb + val);
				//cout << val << " ";
			}
			//cout << ans << endl;
		}
		//cout << ans << endl;
	} 
	cout << ans;
}
int main() {
	boos();
	solve();
}

Compilation message

team.cpp: In function 'void solve()':
team.cpp:67:73: error: no matching function for call to 'max(long long int&, int)'
   67 |      if(u[i][j][h] && u1[j][i][h] && u2[h][i][j])ans = max(ans,i + j + h);
      |                                                                         ^
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 team.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:
team.cpp:67:73: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   67 |      if(u[i][j][h] && u1[j][i][h] && u2[h][i][j])ans = max(ans,i + j + h);
      |                                                                         ^
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 team.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:
team.cpp:67:73: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   67 |      if(u[i][j][h] && u1[j][i][h] && u2[h][i][j])ans = max(ans,i + j + h);
      |                                                                         ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from team.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:
team.cpp:67:73: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   67 |      if(u[i][j][h] && u1[j][i][h] && u2[h][i][j])ans = max(ans,i + j + h);
      |                                                                         ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from team.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:
team.cpp:67:73: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   67 |      if(u[i][j][h] && u1[j][i][h] && u2[h][i][j])ans = max(ans,i + j + h);
      |                                                                         ^
team.cpp:80:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   80 |   for(int j = 0;j < q.size();j++) {
      |                 ~~^~~~~~~~~~