Submission #674658

#TimeUsernameProblemLanguageResultExecution timeMemory
674658vjudge1Kamenčići (COCI21_kamencici)C++17
0 / 70
1 ms336 KiB
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize ("Ofast") #define F first #define S second #define vi vector<int> #define vvi vector<vi> #define pi pair<int, int> #define vpi vector<pi> #define vb vector<bool> #define vvb vector<vb> #define pb push_back #define ppb pop_back #define read(a) for(auto &x:a) cin >> x; #define print(a) for(auto x:a) cout << x << " "; cout << "\n"; #define vc vector<char> #define vvc vector<vc> #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define int long long #define ld long double const int INF = 4e18; void solve(){ int n, k; cin >> n >> k; string s; cin >> s; int a = 0, b = 0, l = 0, r = n-1, t = 0; while(l <= r){ if(a == k){ cout << "NE\n"; return; } if(b == k){ cout << "DA\n"; return; } if(s[l] == 'P'){ l++; t = 1-t; continue; } if(s[r] == 'P'){ r--; t = 1-t; continue; } int dl = 0, dr = 0, ix; ix = l; while(s[ix] == 'C') dl++, ix++; ix = r; while(s[ix] == 'C') dr++, ix--; if(dl > dr){ l++; if(t == 0) a++; else b++; t = 1-t; continue; } else { r--; if(t == 0) a++; else b++; t = 1-t; continue; } } if(a == k){ cout << "NE\n"; return; } if(b == k){ cout << "DA\n"; return; } } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); // #ifndef ONLINE_JUDGE // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); // #endif int tt = 1; // cin >> tt; while(tt--) solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...