QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#605535#2513. A Color Gameucup-team3474WA 28ms7876kbC++201.3kb2024-10-02 17:46:522024-10-02 17:46:52

Judging History

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

  • [2024-10-02 17:46:52]
  • 评测
  • 测评结果:WA
  • 用时:28ms
  • 内存:7876kb
  • [2024-10-02 17:46:52]
  • 提交

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 lastl,lastr;
    
    for(int c=1;c<=7;c++){
        int cnt=0;
        int i=l,j=i;
        bool flag=1;
        while(i<=r){
            if(a[i]==c){
                cnt++;
                i++;
                continue;
            }
            j=i;
            while(j<=r&&a[j]!=c) j++;
            flag&=dp[i][j-1];
            i=j;
        }
        if(flag&&cnt>=m) return true;
    }

    return false;
}

int main(){
    scanf("%s",s+1);
    cin>>m;
    n=strlen(s+1);
    for(int i=1;i<=n;i++){
        if(s[i]=='R') a[i]=1;
        else if(s[i]=='G') a[i]=2;
        else if(s[i]=='B') a[i]=3;
        else if(s[i]=='C') a[i]=4;
        else if(s[i]=='M') a[i]=5;
        else if(s[i]=='Y') a[i]=6;
        else a[i]=7; 
    }
    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: 1ms
memory: 5816kb

input:

BBBRRRRRRGGGB 3

output:

Yes

result:

ok single line: 'Yes'

Test #2:

score: 0
Accepted
time: 1ms
memory: 5632kb

input:

BBBRRRRRRGGGB 4

output:

No

result:

ok single line: 'No'

Test #3:

score: 0
Accepted
time: 1ms
memory: 5868kb

input:

RRRRGGGRRRRRG 3

output:

Yes

result:

ok single line: 'Yes'

Test #4:

score: 0
Accepted
time: 1ms
memory: 5972kb

input:

GMYCGMRMGYMRMKCBKBMKKBMMKBBKMBMRRMGYKKMBKMYRGGBMRMKKKBRCMKYCCKYGYYKKCKRCYGGKGRBCKMYMRCRGBRRYCCKKRRKRCKMMMGCCGYYKMCRGMKCYBMRRKYYRRKGGRBMCKGBBYYGGGBBYBBRCCMGKKGRGRMRRBRCYGGGKBRKCBYCKMMBRCGKCCYYMMCKGRBYRRGBBCGYKBBMKRBBKGCRBYCKMYKMCKMBRMGGYBKBRBMYGGCKYCMYKBRCCGCYRRRKCKCBKCMCYBKRBKMCCYRBKBGGMGMCBGMBMYCCK 1

output:

Yes

result:

ok single line: 'Yes'

Test #5:

score: -100
Wrong Answer
time: 28ms
memory: 7876kb

input:

KKCCCCCKYYYYYYKKKCRRCCBBBGGMMGCKKBBBBBRCCRRCRRYYCCYYBGGGBKKKBKKKCMKKMCCCGGGCCCCBBBCCKMMMKCCYYBBCCCCCCCCCYYCCCCBMMBRRRBBGGMKKBYMMMYYBBBBYYYYKCCCMMCKKMMMKKGGMBBRRBBBBKKBBBMMMMKKMMMKKKMMYYGMYYYMRRBMMMBGRRGGMMCCGRRBBBGCGGGCBBBCCBGGGGCRKKBBBRRYYYBBBYYKKKYYYBBYYBBBBCCCRKYGGGYYKKKKKKKKKRCCCYKKRRRKKMMMKMMC 2

output:

No

result:

wrong answer 1st lines differ - expected: 'Yes', found: 'No'