제출 #717234

#제출 시각아이디문제언어결과실행 시간메모리
717234JuanKamenčići (COCI21_kamencici)C++14
10 / 70
1087 ms3008 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define pii pair<int, int> #define ff first #define ss second const int maxn = 55; bool v[maxn]; int dp[maxn][maxn][maxn][maxn][3]; bool solve(int l, int r, int k1, int k2, int p){ if(k1==0) return 0; if(k2==0) return 1; if(dp[l][r][k1][k2][p]) return dp[l][r][k1][k2][p]; if(p==1){ return dp[l][r][k1][k2][p] = max(solve(l+1, r, k1-v[l], k2, 2), solve(l, r-1, k1-v[r], k2, 2)); } else{ return dp[l][r][k1][k2][p] = min(solve(l+1, r, k1, k2-v[l], 1), solve(l, r-1, k1, k2-v[r], 1)); } } int32_t main(){ int n, k; cin >> n >> k; for(int i = 0; i < n; i++){ char c; cin >> c; if(c=='C') v[i] = 1; } if(solve(0, n-1, k, k, 1)) cout << "DA\n"; else cout << "NE\n"; }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'bool solve(long long int, long long int, long long int, long long int, long long int)':
Main.cpp:19:34: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   19 |       return dp[l][r][k1][k2][p] = max(solve(l+1, r, k1-v[l], k2, 2), solve(l, r-1, k1-v[r], k2, 2));
      |              ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:22:34: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   22 |       return dp[l][r][k1][k2][p] = min(solve(l+1, r, k1, k2-v[l], 1), solve(l, r-1, k1, k2-v[r], 1));
      |              ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...