답안 #587778

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
587778 2022-07-02T11:06:25 Z Tekor Copy and Paste 3 (JOI22_copypaste3) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pll pair <ll,ll>
#define mp make_pair
#define f first
#define s second
#define all(v) v.begin(),v.end()
void boos() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
const int N = 1e3 + 1;
const ll p = 433,p1 = 383;
const ll INF = (ll)1e9 + 7ll;
ll binpow(ll a,ll b) {
	ll ans = 1,k = a;
	while(b) { 
		if(b % 2)ans *= k;
		ans %= INF;
		k *= k;
		k %= INF;
		b /= 2ll;
	}
	return ans;
}
ll has[N],has1[N],st[N],st1[N];
ll dp[N][N];
ll cc[N];
pll calc(int l,int r) {
	ll tek = (has[r] - has[l - 1] + INF) % INF;
	tek = (tek * st[l]) % INF;
	ll tek1 = (has1[r] - has1[l - 1] + INF) % INF;
	tek1 = (tek1 * st1[l]) % INF;
	return mp(tek,tek1);
}
void solve() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	ll a,b,c;
	cin >> a >> b >> c;
	s = "0" + s;
	ll tek = p,tek1 = p1;
	st[1] = binpow(tek,INF - 2);
	st1[1] = binpow(tek1,INF - 2);
	has[1] = (s[1] - 'a' + 1ll);
	has1[1] = has[1];
	for(int i = 2;i <= n;i++) {
		ll val = (s[i] - 'a' + 1ll);
		has[i] = (has[i - 1] + (tek * val) % INF) % INF;
		has1[i] = (has1[i - 1] + (tek1 * val) % INF) % INF;
		tek = (tek * p) % INF;
		tek1 = (tek1 * p1) % INF;
		st[i] = binpow(tek,INF - 2);
		st1[i] = binpow(tek1,INF - 2);
	}
	for(int i = 1;i <= n;i++)dp[i][i] = a;
//	for(int sz = 2;sz <= n;sz++) {
//		for(int l = 1;l <= n - sz + 1;l++) {
//			int r = l + sz - 1;
//			dp[l][r] = dp[l][r - 1] + a;
//			for(int sz1 = 1;sz1 * 2 <= sz;sz1++) {
//				for(int h = l;h <= r;h++)cc[h] = 1;
//				for(int h = r - 2 * sz1 + 1;h >= l;h--) {
//					cc[h] = max(cc[h],cc[h + 1]);
//					if(calc(h,h + sz1 - 1) == calc(r - sz1 + 1,r)) {
//						//cout << h << " " << h + sz1 - 1 << " === " << r - sz1 + 1 << " " << r << endl;
//						cc[h] = max(cc[h],cc[h + sz1] + 1);
//					}
//					dp[l][r] = min(dp[l][r],cc[h] * c + b + a * (ll)(sz - cc[h] * sz1) + dp[r - sz1 + 1][r]);
//				}
//			}
//		}
//	}
	for(int r = 2;r <= n;r++) {
		cc[r] = 0;
		for(int l = r - 1;l >= 1;l--) {
			dp[l][r] = dp[l][r - 1] + a;
			dp[l][r] = min(dp[l][r],dp[l + 1][r] + a);
			cc[l] = 0;
			int sz = r -l + 1;
			for(int sz1 = 1;sz1 * 2 <= sz;sz1++) {
				cc[l] = max(cc[l],cc[l + 1]);
				if(calc(l,l + sz1 - 1) == calc(r - sz1 + 1,r)) {
					if(h >= r - sz1 + 1)cc[l] = max(cc[l],2);
					else cc[l] = max(cc[l],cc[l + sz1] + 1);
				}
		javascript:tab_clicked(1)		dp[l][r] = min(dp[l][r],cc[l] * c + b + a * (ll)(sz - cc[l] * sz1) + dp[r - sz1 + 1][r]);
			}
		}
	}
	cout << dp[1][n];
}
int main() {
	boos();
	solve();
}

Compilation message

copypaste3.cpp: In function 'void solve()':
copypaste3.cpp:89:9: error: 'h' was not declared in this scope
   89 |      if(h >= r - sz1 + 1)cc[l] = max(cc[l],2);
      |         ^
copypaste3.cpp:89:45: error: no matching function for call to 'max(long long int&, int)'
   89 |      if(h >= r - sz1 + 1)cc[l] = max(cc[l],2);
      |                                             ^
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 copypaste3.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:
copypaste3.cpp:89:45: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   89 |      if(h >= r - sz1 + 1)cc[l] = max(cc[l],2);
      |                                             ^
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 copypaste3.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:
copypaste3.cpp:89:45: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   89 |      if(h >= r - sz1 + 1)cc[l] = max(cc[l],2);
      |                                             ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from copypaste3.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:
copypaste3.cpp:89:45: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   89 |      if(h >= r - sz1 + 1)cc[l] = max(cc[l],2);
      |                                             ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from copypaste3.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:
copypaste3.cpp:89:45: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   89 |      if(h >= r - sz1 + 1)cc[l] = max(cc[l],2);
      |                                             ^
copypaste3.cpp:92:14: error: 'tab_clicked' was not declared in this scope
   92 |   javascript:tab_clicked(1)  dp[l][r] = min(dp[l][r],cc[l] * c + b + a * (ll)(sz - cc[l] * sz1) + dp[r - sz1 + 1][r]);
      |              ^~~~~~~~~~~
copypaste3.cpp:92:3: warning: label 'javascript' defined but not used [-Wunused-label]
   92 |   javascript:tab_clicked(1)  dp[l][r] = min(dp[l][r],cc[l] * c + b + a * (ll)(sz - cc[l] * sz1) + dp[r - sz1 + 1][r]);
      |   ^~~~~~~~~~