Submission #674288

#TimeUsernameProblemLanguageResultExecution timeMemory
674288Farhan_HYKamenčići (COCI21_kamencici)C++14
70 / 70
209 ms350572 KiB
#include<bits/stdc++.h> #define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define T int t;cin >> t;while(t--) #define int long long #define F first #define S second using namespace std; const int mod = 1e9 + 7; const int N = 355; int n, k, a[N], dp[N][N][N]; int Rec(int l, int r, int sum, int s) { int x = l - 1 + r - n; if (x % 2) { if (l == r) return s + a[r] < k; if (a[l] + s == k && a[r] + s == k) return 0; int &ret = dp[l][r][sum]; if (ret != -1) return ret; ret = 0; ret |= !Rec(l + 1, r, sum, s + a[l]); ret |= !Rec(l, r - 1, sum, s + a[r]); return ret; } else { if (l == r) return sum + a[r] < k; if (a[r] + sum == k && a[l] + sum == k) return 0; int &ret = dp[l][r][sum]; if (ret != -1) return ret; ret = 0; ret |= !Rec(l + 1, r, sum + a[l], s); ret |= !Rec(l, r - 1, sum + a[r], s); return ret; } } main() { cin >> n >> k; string s; cin >> s; for(int i = 0; i < s.size(); i++) a[i + 1] = s[i] == 'C'; memset(dp, -1, sizeof dp); if (Rec(1, n, 0, 0)) cout << "DA"; else cout << "NE"; }

Compilation message (stderr)

Main.cpp:36:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   36 | main() {
      | ^~~~
Main.cpp: In function 'int main()':
Main.cpp:40:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     for(int i = 0; i < s.size(); i++)
      |                    ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...