This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*#pragma GCC target ("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")/**/
#include<bits/stdc++.h>
/**/
//typedef int ll;
typedef long long ll;
typedef unsigned long long ull;
/*typedef __int128 vll;
typedef unsigned __int128 uvll;*/
#define llll std::pair<ll , ll>
#define pb push_back
#define pf push_front
#define halo cout << "hello\n"
#define fi first
#define sec second
#define all(a) a.begin() , a.end()
const ll limit = 1e15+7;
const ll ous = 2e5 + 7;
const ll dx[4] = {-1 , 0 , 1 , 0} , dy[4] = {0,1,0,-1};
std::vector<ll> ar(360);
ll dp[360][360][360];
ll n , k;
ll solv(ll i , ll j , ll tkz){
ll p = dp[i][j][tkz];
if(p == -1){
ll bp = (i == 0?0:ar[i-1]) + (ar[n-1] - ar[j]) - tkz;
if(tkz >= k){
p = 0;
}
else if(bp >= k){
p = 1;
}
else{
if(!solv(i+1 , j , bp) || !solv(i , j-1 , bp)){
p = 1;
}
else{
p = 0;
}
}
}
dp[i][j][tkz] = p;
return p;
}
void solve(){
std::cin >> n >> k;
std::string h;std::cin >> h;
h.pb('0');
memset(dp , -1 , sizeof(dp));
ar[0] = h[0] == 'C';
for(ll i = 1;n>=i;i++){
ar[i] = ar[i-1] + (h[i] == 'C');
}
ll u = solv(0 , n-1 , 0);
if(u){
std::cout << "DA\n";
}
else{
std::cout << "NE\n";
}
return;/**/
}
signed main(){
std::ios_base::sync_with_stdio(false);std::cin.tie(NULL);
ll t=1;
//std::cin >> t;
ll o = 1;
while(t--){
//cout << "Case " << o++ << ":\n";
solve();
}
return 0;
}
Compilation message (stderr)
Main.cpp:5:78: warning: "/*" within comment [-Wcomment]
5 | #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")/**/
|
Main.cpp: In function 'int main()':
Main.cpp:70:8: warning: unused variable 'o' [-Wunused-variable]
70 | ll o = 1;
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |