Submission #1118490

#TimeUsernameProblemLanguageResultExecution timeMemory
1118490manhlinh1501Kamenčići (COCI21_kamencici)C++17
70 / 70
80 ms96936 KiB
#include<bits/stdc++.h> using namespace std; using i64 = long long; template<class X, class Y> bool minimize(X &x, const Y &y) { if (x > y) { x = y; return true; } return false; } template<class X, class Y> bool maximize(X &x, const Y &y) { if (x < y) { x = y; return true; } return false; } const int MAXN = 355; int N, K; char a[MAXN]; int dp[MAXN][MAXN][MAXN]; int calc(int l, int r, int x, int y, int turn) { if(x == 0) return dp[l][r][x] = -1; if(y == 0) return dp[l][r][x] = 1; int &res = dp[l][r][x]; if(res != 0) return res; if(turn == 0) res = max(calc(l + 1, r, x - (a[l] == 'C'), y, 1), calc(l, r - 1, x - (a[r] == 'C'), y, 1)); else res = min(calc(l + 1, r, x, y - (a[l] == 'C'), 0), calc(l, r - 1, x, y - (a[r] == 'C'), 0)); return res; } signed main() { #define task "" if(fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> N >> K; for(int i = 1; i <= N; i++) cin >> a[i]; cout << (calc(1, N, K, K, 0) == 1 ? "DA" : "NE"); return (0 ^ 0); }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:41:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:42:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |         freopen(task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...