Submission #5285574


Source Code Expand

Copy
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧  
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     
    /   \     | |     
    /   / ̄ ̄ ̄ ̄/  |  
  __(__ニつ/     _/ .| .|____  
     \/____/ (u ⊃  
---------------------------------------------------------------------------------------------------*/





int N; string S; int A, B, C, D;
int dp[4040][4040];
//---------------------------------------------------------------------------------------------------
#define yes "Yes"
#define no "No"
string solve() {
int maru = 0, batsu = 0;
	fore(c, S) {
		if (c == 'o') maru++;
		else batsu++;
	}

	if (A + B + C != maru or A + B + D != batsu) return no;

	S += "#";

	rep(i, 0, N + 1) rep(a, 0, A + 1) dp[i][a] = inf;
	dp[0][A] = B;
	rep(i, 0, N) rep(a, 0, A + 1) if(dp[i][a] < inf) {
		chmin(dp[i + 1][a], dp[i][a]);

		if (S[i] == 'o' and S[i + 1] == 'x' and 0 < a) chmin(dp[i + 2][a - 1], dp[i][a]);
		if (S[i] == 'x' and S[i + 1] == 'o' and 0 < dp[i][a]) chmin(dp[i + 2][a], dp[i][a] - 1);
	}

	if (dp[N][0] == 0) return yes;
	return no;
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> S >> A >> B >> C >> D;
	cout << solve() << endl;
}

Submission Info

Submission Time
Task E - ox Concatenation
User hamayanhamayan
Language C++14 (GCC 5.4.1)
Score 300
Code Size 2202 Byte
Status RE
Exec Time 257 ms
Memory 64336 KB

Judge Result

Set Name all sub sample
Score / Max Score 0 / 300 300 / 300 0 / 0
Status
AC × 42
RE × 29
AC × 35
AC × 4
Set Name Test Cases
all sample01, sample02, sample03, sample04, sub_test01, sub_test02, sub_test03, sub_test04, sub_test05, sub_test06, sub_test07, sub_test08, sub_test09, sub_test10, sub_test11, sub_test12, sub_test13, sub_test14, sub_test15, sub_test16, sub_test17, sub_test18, sub_test19, sub_test20, sub_test21, sub_test22, sub_test23, sub_test24, sub_test25, sub_test26, sub_test27, sub_test28, sub_test29, sub_test30, sub_test31, sub_test32, sub_test33, sub_test34, sub_test35, test36, test37, test38, test39, test40, test41, test42, test43, test44, test45, test46, test47, test48, test49, test50, test51, test52, test53, test54, test55, test56, test57, test58, test59, test60, test61, test62, test63, test64, test65, test66, test67
sub sub_test01, sub_test02, sub_test03, sub_test04, sub_test05, sub_test06, sub_test07, sub_test08, sub_test09, sub_test10, sub_test11, sub_test12, sub_test13, sub_test14, sub_test15, sub_test16, sub_test17, sub_test18, sub_test19, sub_test20, sub_test21, sub_test22, sub_test23, sub_test24, sub_test25, sub_test26, sub_test27, sub_test28, sub_test29, sub_test30, sub_test31, sub_test32, sub_test33, sub_test34, sub_test35
sample sample01, sample02, sample03, sample04
Case Name Status Exec Time Memory
sample01 AC 1 ms 256 KB
sample02 AC 1 ms 256 KB
sample03 AC 1 ms 256 KB
sample04 AC 1 ms 256 KB
sub_test01 AC 27 ms 56832 KB
sub_test02 AC 17 ms 60288 KB
sub_test03 AC 22 ms 58496 KB
sub_test04 AC 25 ms 58624 KB
sub_test05 AC 19 ms 48384 KB
sub_test06 AC 13 ms 56064 KB
sub_test07 AC 28 ms 56960 KB
sub_test08 AC 16 ms 60288 KB
sub_test09 AC 20 ms 56576 KB
sub_test10 AC 1 ms 256 KB
sub_test11 AC 28 ms 58880 KB
sub_test12 AC 15 ms 50048 KB
sub_test13 AC 20 ms 52352 KB
sub_test14 AC 23 ms 54528 KB
sub_test15 AC 19 ms 52352 KB
sub_test16 AC 12 ms 51968 KB
sub_test17 AC 33 ms 63232 KB
sub_test18 AC 18 ms 62464 KB
sub_test19 AC 19 ms 54400 KB
sub_test20 AC 1 ms 256 KB
sub_test21 AC 31 ms 62976 KB
sub_test22 AC 18 ms 62336 KB
sub_test23 AC 28 ms 62848 KB
sub_test24 AC 28 ms 62848 KB
sub_test25 AC 27 ms 62720 KB
sub_test26 AC 15 ms 62208 KB
sub_test27 AC 33 ms 63232 KB
sub_test28 AC 18 ms 62336 KB
sub_test29 AC 23 ms 62720 KB
sub_test30 AC 1 ms 256 KB
sub_test31 AC 1 ms 256 KB
sub_test32 AC 13 ms 62208 KB
sub_test33 AC 33 ms 63232 KB
sub_test34 AC 26 ms 62720 KB
sub_test35 AC 26 ms 62720 KB
test36 RE 195 ms 64208 KB
test37 RE 128 ms 64336 KB
test38 RE 138 ms 64208 KB
test39 RE 131 ms 64128 KB
test40 RE 169 ms 64336 KB
test41 RE 109 ms 62672 KB
test42 RE 138 ms 64128 KB
test43 RE 115 ms 64128 KB
test44 RE 154 ms 64208 KB
test45 AC 2 ms 512 KB
test46 RE 233 ms 64276 KB
test47 RE 122 ms 64276 KB
test48 RE 173 ms 64276 KB
test49 RE 159 ms 64276 KB
test50 RE 178 ms 64276 KB
test51 RE 125 ms 64276 KB
test52 RE 256 ms 64276 KB
test53 RE 135 ms 64276 KB
test54 RE 177 ms 64276 KB
test55 AC 2 ms 720 KB
test56 RE 242 ms 64276 KB
test57 RE 127 ms 64276 KB
test58 RE 155 ms 64276 KB
test59 RE 218 ms 64276 KB
test60 RE 174 ms 64276 KB
test61 RE 134 ms 64276 KB
test62 RE 226 ms 64276 KB
test63 RE 131 ms 64276 KB
test64 RE 180 ms 64276 KB
test65 AC 2 ms 720 KB
test66 RE 196 ms 64276 KB
test67 RE 257 ms 64276 KB