QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#762042#2513. A Color GameSanguineChameleon#WA 1ms3800kbC++201.5kb2024-11-19 12:50:232024-11-19 12:50:24

Judging History

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

  • [2024-11-19 12:50:24]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3800kb
  • [2024-11-19 12:50:23]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define f first
#define s second
#define mp make_pair
#define eb emplace_back
#define pb push_back
typedef pair<int,int> pii;

const int mxn=505;

bool dp[mxn][mxn];
char same[mxn][mxn];

int32_t main() {
    ios_base::sync_with_stdio(false);cin.tie(0);
    string s;
    int n,m;
    cin>>s>>m;
    n=s.length();
    
    for(int l=0;l<n;l++){
        same[l][l]=s[l];
        for(int r=l+1;r<n;r++){
            if(s[r]==same[l][r-1])same[l][r]=s[r];
            else same[l][r]='x';
        }
    }

    for(int l=0;l+m<=n;l++){
        dp[l][l+m-1] = (same[l][l+m-1]!='x');
    }

    for(int sz=m;sz<=n;sz++){
        for(int l=0;l+sz<=n;l++){
            int r = l+sz-1;
            if(!dp[l][r])continue;
            // cout<<"Possible: "<<l<<' '<<r<<'\n';

            if(l>0 && s[l]==s[l-1])dp[l-1][r]=1;
            if(r+1 < n && s[r]==s[r+1])dp[l][r+1]=1;

            for(int i=0;i<=m;i++){
                if(l-i < 0)continue;
                if(r+m-i >= n)continue;
                if(l-i<=l-1 && same[l-i][l-1]=='x')continue;
                if(r+1<=r+m-i && same[r+1][r+m-i]=='x')continue;
                if(l-i <= l-1 && r+1 <= r+m-i && same[l-i][l-1] != same[r+1][r+m-i])continue;
                dp[l-i][r+m-i]=true;
            }
        }
    }
    if(dp[0][n-1])cout<<"Yes\n";
    else cout<<"No\n";
}
/*
BBBRRRRRRGGGB 3
BBBRRRRRRGGGB 4
*/

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3524kb

input:

BBBRRRRRRGGGB 3

output:

Yes

result:

ok single line: 'Yes'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

BBBRRRRRRGGGB 4

output:

No

result:

ok single line: 'No'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3800kb

input:

RRRRGGGRRRRRG 3

output:

Yes

result:

ok single line: 'Yes'

Test #4:

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

input:

GMYCGMRMGYMRMKCBKBMKKBMMKBBKMBMRRMGYKKMBKMYRGGBMRMKKKBRCMKYCCKYGYYKKCKRCYGGKGRBCKMYMRCRGBRRYCCKKRRKRCKMMMGCCGYYKMCRGMKCYBMRRKYYRRKGGRBMCKGBBYYGGGBBYBBRCCMGKKGRGRMRRBRCYGGGKBRKCBYCKMMBRCGKCCYYMMCKGRBYRRGBBCGYKBBMKRBBKGCRBYCKMYKMCKMBRMGGYBKBRBMYGGCKYCMYKBRCCGCYRRRKCKCBKCMCYBKRBKMCCYRBKBGGMGMCBGMBMYCCK 1

output:

Yes

result:

ok single line: 'Yes'

Test #5:

score: -100
Wrong Answer
time: 1ms
memory: 3792kb

input:

KKCCCCCKYYYYYYKKKCRRCCBBBGGMMGCKKBBBBBRCCRRCRRYYCCYYBGGGBKKKBKKKCMKKMCCCGGGCCCCBBBCCKMMMKCCYYBBCCCCCCCCCYYCCCCBMMBRRRBBGGMKKBYMMMYYBBBBYYYYKCCCMMCKKMMMKKGGMBBRRBBBBKKBBBMMMMKKMMMKKKMMYYGMYYYMRRBMMMBGRRGGMMCCGRRBBBGCGGGCBBBCCBGGGGCRKKBBBRRYYYBBBYYKKKYYYBBYYBBBBCCCRKYGGGYYKKKKKKKKKRCCCYKKRRRKKMMMKMMC 2

output:

No

result:

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