Submission #1077211

#TimeUsernameProblemLanguageResultExecution timeMemory
1077211shiroboyyKamenčići (COCI21_kamencici)C++14
70 / 70
120 ms171740 KiB
#include <bits/stdc++.h> #define mp make_pair #define pb push_back #define endl "\n" #define fi first #define se second #define SZ(x) (x).size() #define ALL(x) (x).begin(), (x).end() #define BIT(x, i) (((x) >> (i)) & 1) #define MASK(x) (1LL << (x)) #define rep(i, l, r) for (int i = (l), _r = (r); i <= _r; i++) #define rev(i, r, l) for (int i = (r), _l = (l); i >= _l; i--) using namespace std; typedef vector<int> vi; typedef pair<int, int> pi; typedef long long ll; typedef unsigned long long ull; typedef long double ld; template<class X, class Y> inline bool maximize(X &x, const Y &y) {return x < y ? x = y, 1 : 0;} template<class X, class Y> inline bool minimize(X &x, const Y &y) {return x > y ? x = y, 1 : 0;} const int MAX = 355; const int INF = 1e9 + 7; const int MOD = 1e9 + 7; int num_pebble, num_red; string pebble; int cnt[MAX]; int f[MAX][MAX][MAX]; void input() { cin >> num_pebble >> num_red >> pebble; } void solve() { rep(i, 1, num_pebble) cnt[i] = cnt[i - 1] + (pebble[i] == 'C'); rep(len, 1, num_pebble) { rep(u, 0, num_pebble - 1) { int c = u + len - 1; int total = 0; rep(i, 0, u - 1) total += (pebble[i] == 'C'); rep(i, c + 1, num_pebble - 1) total += (pebble[i] == 'C'); rep(k, 0, total) { int o = total - k; if (k >= num_red) f[u][c][k] = 0; else if (o >= num_red) f[u][c][k] = 1; else { if (len == 1) { f[u][c][k] = 0; continue; } f[u][c][k] = (!f[u + 1][c][o] or !f[u][c - 1][o]); } } } } cout << (f[0][num_pebble - 1][0] ? "DA" : "NE") << endl; } int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define task "kamencici" if (fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } int test_case = 1; //cin >> test_case; while (test_case--) { input(); solve(); } cerr << "\nTime elapsed: " << clock() * 1.0 / CLOCKS_PER_SEC << " seconds" << endl; }

Compilation message (stderr)

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