QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#728625 | #2513. A Color Game | ucup-team5226# | WA | 7ms | 4088kb | C++20 | 1.9kb | 2024-11-09 15:32:31 | 2024-11-09 15:32:40 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ov4(a, b, c, d, name, ...) name
#define rep3(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define rep2(i, a, b) rep3(i, a, b, 1)
#define rep1(i, n) rep2(i, 0, n)
#define rep0(n) rep1(aaaaa, n)
#define rep(...) ov4(__VA_ARGS__, rep3, rep2, rep1, rep0)(__VA_ARGS__)
#define all(v) v.begin(), v.end()
using pl = pair<ll, ll>;
using vl = vector<ll>;
using vpl = vector<pl>;
template <size_t N>
using al = array<ll, N>;
template <size_t N>
using val = vector<al<N>>;
using sl = set<ll>;
template <class T>
using vc = vector<T>;
template <class T>
using vvc = vc<vc<T>>;
using vvl = vvc<ll>;
using str = string;
void solve() {
str s;
ll m;
cin >> s >> m;
ll n = s.size();
vvl dp(n, vl(n + 1));
rep(i, n) {
dp[i][i] = true;
}
rep(d, 1, n + 1) {
rep(i, n - d + 1) {
const ll j = i + d;
rep(k, i, j) {
dp[i][j] |= dp[i][k] && dp[k][j];
}
if (s[i] == s[j - 1]) {
ll t = 0;
ll l = j;
ll r = i;
rep(k, i, j) {
if (s[k] != s[i]) {
l = k;
break;
}
}
rep(k, i, j) {
if (s[k] != s[i]) {
r = k + 1;
}
}
if (l < r) {
if (l - i + j - r >= m) {
dp[i][j] |= dp[l][r];
}
} else if (j - i >= m) {
dp[i][j] = true;
}
}
}
}
cout << (dp[0][n] ? "Yes" : "No") << endl;
}
int main() {
cin.tie(0)->sync_with_stdio(0);
cout << fixed << setprecision(20);
ll t = 1;
// cin >> t;
rep(t) solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3836kb
input:
BBBRRRRRRGGGB 3
output:
Yes
result:
ok single line: 'Yes'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
BBBRRRRRRGGGB 4
output:
No
result:
ok single line: 'No'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
RRRRGGGRRRRRG 3
output:
Yes
result:
ok single line: 'Yes'
Test #4:
score: 0
Accepted
time: 3ms
memory: 3976kb
input:
GMYCGMRMGYMRMKCBKBMKKBMMKBBKMBMRRMGYKKMBKMYRGGBMRMKKKBRCMKYCCKYGYYKKCKRCYGGKGRBCKMYMRCRGBRRYCCKKRRKRCKMMMGCCGYYKMCRGMKCYBMRRKYYRRKGGRBMCKGBBYYGGGBBYBBRCCMGKKGRGRMRRBRCYGGGKBRKCBYCKMMBRCGKCCYYMMCKGRBYRRGBBCGYKBBMKRBBKGCRBYCKMYKMCKMBRMGGYBKBRBMYGGCKYCMYKBRCCGCYRRRKCKCBKCMCYBKRBKMCCYRBKBGGMGMCBGMBMYCCK 1
output:
Yes
result:
ok single line: 'Yes'
Test #5:
score: 0
Accepted
time: 7ms
memory: 3860kb
input:
KKCCCCCKYYYYYYKKKCRRCCBBBGGMMGCKKBBBBBRCCRRCRRYYCCYYBGGGBKKKBKKKCMKKMCCCGGGCCCCBBBCCKMMMKCCYYBBCCCCCCCCCYYCCCCBMMBRRRBBGGMKKBYMMMYYBBBBYYYYKCCCMMCKKMMMKKGGMBBRRBBBBKKBBBMMMMKKMMMKKKMMYYGMYYYMRRBMMMBGRRGGMMCCGRRBBBGCGGGCBBBCCBGGGGCRKKBBBRRYYYBBBYYKKKYYYBBYYBBBBCCCRKYGGGYYKKKKKKKKKRCCCYKKRRRKKMMMKMMC 2
output:
Yes
result:
ok single line: 'Yes'
Test #6:
score: -100
Wrong Answer
time: 3ms
memory: 4088kb
input:
BYCCCYYBMMMMMMMMGYYYBBBYGBBBGGGKKKKKKGGGKKKBBBBKKBBBYYGGGGYGGGMGGGGMCMCCCMMMYYYYYYYYYYYCCCGGGCCRRRCRRBBBBRCCCCCGYCCCCCCYYCCCGGMGGRRRBCCCBMMMMBRCCCCGYYYGRYYYRRMMMMMRRRRMCBBGGGBBGYYYGGGCCGGGGMMBBGGRRRRGBRRRRYYYYBCCCYCCKKKMMMMCCYGGGYCBBBYYYYCCCCYCCCMMMMYYCBBBBBBBCCCCCGGGGCCCGGGGCCBBBBBGGGGMMMBKKKKMMM 3
output:
No
result:
wrong answer 1st lines differ - expected: 'Yes', found: 'No'