Submission #728569

#TimeUsernameProblemLanguageResultExecution timeMemory
728569aykhnKamenčići (COCI21_kamencici)C++14
70 / 70
197 ms179968 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define OPT ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0) #define pii pair<int,int> #define pll pair<ll,ll> #define endl "\n" #define all(v) v.begin(),v.end() #define mpr make_pair #define pb push_back #define ts to_string #define inf 0x3F3F3F3F #define bpc __builtin_popcount int k; string s; bool player2(int l, int r, int cnt1, int cnt2); vector<vector<vector<short>>> dp1(351, vector<vector<short>> (351, vector<short> (351, -1))); vector<vector<vector<short>>> dp2(351, vector<vector<short>> (351, vector<short> (351, -1))); bool player1(int l, int r, int cnt1, int cnt2)// a || b || c { if (cnt2 == k) return true; if (dp1[l][r][cnt2] != -1) return dp1[l][r][cnt2]; bool a, b; a = b = false; if (s[l] == 'C') a = player2(l + 1, r, cnt1 + 1, cnt2); else a = player2(l + 1, r, cnt1, cnt2); if (s[r] == 'C') b = player2(l, r - 1, cnt1 + 1, cnt2); else b = player2(l, r - 1, cnt1, cnt2); return dp1[l][r][cnt2] = (a || b); } bool player2(int l, int r, int cnt1, int cnt2)// a && b && c { if (cnt1 == k) return false; if (dp2[l][r][cnt1] != -1) return dp2[l][r][cnt1]; bool a, b; a = b = false; if (s[l] == 'C') a = player1(l + 1, r, cnt1, cnt2 + 1); else a = player1(l + 1, r, cnt1, cnt2); if (s[r] == 'C') b = player1(l, r - 1, cnt1, cnt2 + 1); else b = player1(l, r - 1, cnt1, cnt2); return dp2[l][r][cnt1] = (a && b); } int main() { int n; cin >> n >> k; cin >> s; cout << (player1(0, n - 1, 0, 0) ? "DA" : "NE") << endl; return 0; }

Compilation message (stderr)

Main.cpp: In function 'bool player1(int, int, int, int)':
Main.cpp:39:28: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   39 |     return dp1[l][r][cnt2] = (a || b);
Main.cpp: In function 'bool player2(int, int, int, int)':
Main.cpp:55:28: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   55 |     return dp2[l][r][cnt1] = (a && b);
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...