QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#605521 | #2513. A Color Game | ucup-team3474 | WA | 5ms | 3960kb | C++20 | 1.0kb | 2024-10-02 17:38:43 | 2024-10-02 17:38:46 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=1919810;
typedef long long ll;
typedef pair<ll,ll> PII;
ll n,m,k;
ll a[N],b[N];
char s[N];
bool dp[514][514];
bool check(int l,int r){
for(int i=l;i<r;i++){
if(dp[l][i]&&dp[i+1][r]) return true;
}
int len=r-l+1;
int i=l,j=r;
while(i<=r&&s[l]==s[i]) i++;
while(j>=i&&s[j]==s[r]) j--;
if(i>r){
if(len>=m) return true;
else return false;
}
if(s[l]!=s[r]) return false;
for(int c=l;c<=i;c++){
for(int d=j;d<=r;d++){
int len2=d-c+1;
if(len-len2>=m&&dp[c][d]) return true;
}
}
return false;
}
int main(){
scanf("%s",s+1);
cin>>m;
n=strlen(s+1);
for(int len=1;len<=n;len++){
for(int i=1;i+len-1<=n;i++){
int l=i,r=i+len-1;
dp[l][r]=check(l,r);
// cout<<l<<" "<<r<<" "<<dp[l][r]<<endl;
}
}
if(dp[1][n]) puts("Yes");
else puts("No");
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3612kb
input:
BBBRRRRRRGGGB 3
output:
Yes
result:
ok single line: 'Yes'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3848kb
input:
BBBRRRRRRGGGB 4
output:
No
result:
ok single line: 'No'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
RRRRGGGRRRRRG 3
output:
Yes
result:
ok single line: 'Yes'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3896kb
input:
GMYCGMRMGYMRMKCBKBMKKBMMKBBKMBMRRMGYKKMBKMYRGGBMRMKKKBRCMKYCCKYGYYKKCKRCYGGKGRBCKMYMRCRGBRRYCCKKRRKRCKMMMGCCGYYKMCRGMKCYBMRRKYYRRKGGRBMCKGBBYYGGGBBYBBRCCMGKKGRGRMRRBRCYGGGKBRKCBYCKMMBRCGKCCYYMMCKGRBYRRGBBCGYKBBMKRBBKGCRBYCKMYKMCKMBRMGGYBKBRBMYGGCKYCMYKBRCCGCYRRRKCKCBKCMCYBKRBKMCCYRBKBGGMGMCBGMBMYCCK 1
output:
Yes
result:
ok single line: 'Yes'
Test #5:
score: 0
Accepted
time: 1ms
memory: 3956kb
input:
KKCCCCCKYYYYYYKKKCRRCCBBBGGMMGCKKBBBBBRCCRRCRRYYCCYYBGGGBKKKBKKKCMKKMCCCGGGCCCCBBBCCKMMMKCCYYBBCCCCCCCCCYYCCCCBMMBRRRBBGGMKKBYMMMYYBBBBYYYYKCCCMMCKKMMMKKGGMBBRRBBBBKKBBBMMMMKKMMMKKKMMYYGMYYYMRRBMMMBGRRGGMMCCGRRBBBGCGGGCBBBCCBGGGGCRKKBBBRRYYYBBBYYKKKYYYBBYYBBBBCCCRKYGGGYYKKKKKKKKKRCCCYKKRRRKKMMMKMMC 2
output:
Yes
result:
ok single line: 'Yes'
Test #6:
score: -100
Wrong Answer
time: 5ms
memory: 3960kb
input:
BYCCCYYBMMMMMMMMGYYYBBBYGBBBGGGKKKKKKGGGKKKBBBBKKBBBYYGGGGYGGGMGGGGMCMCCCMMMYYYYYYYYYYYCCCGGGCCRRRCRRBBBBRCCCCCGYCCCCCCYYCCCGGMGGRRRBCCCBMMMMBRCCCCGYYYGRYYYRRMMMMMRRRRMCBBGGGBBGYYYGGGCCGGGGMMBBGGRRRRGBRRRRYYYYBCCCYCCKKKMMMMCCYGGGYCBBBYYYYCCCCYCCCMMMMYYCBBBBBBBCCCCCGGGGCCCGGGGCCBBBBBGGGGMMMBKKKKMMM 3
output:
No
result:
wrong answer 1st lines differ - expected: 'Yes', found: 'No'