QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#605521#2513. A Color Gameucup-team3474WA 5ms3960kbC++201.0kb2024-10-02 17:38:432024-10-02 17:38:46

Judging History

你现在查看的是最新测评结果

  • [2024-10-02 17:38:46]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:3960kb
  • [2024-10-02 17:38:43]
  • 提交

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'