제출 #716090

#제출 시각아이디문제언어결과실행 시간메모리
716090JuanKamenčići (COCI21_kamencici)C++17
0 / 70
0 ms340 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 = 50; 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 << "NA\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:30: 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:30: 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...