QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#581289 | #2513. A Color Game | CSQ# | WA | 4ms | 4412kb | C++14 | 1.3kb | 2024-09-22 11:35:52 | 2024-09-22 11:35:52 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define all(x) begin(x),end(x)
#define sz(x) (int)(x).size();
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
int dp[500][500];
int main()
{
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
int m;
string s;
cin>>s>>m;
int n = sz(s);
for(int i=0;i<n;i++){
for(int j=i;j<n;j++){
if(s[j] != s[i])break;
if(j-i+1 >= m)dp[i][j] = 1;
}
}
for(int len = 0;len<n;len++){
for(int i=0;i+len<n;i++){
int l = i;
int r = i+len;
for(int j=l;j<r;j++){
if(dp[l][j] && dp[j+1][r])dp[l][r] = 1;
}
if(!dp[l][r])continue;
int l0 = l-1;
int r0 = r+1;
while(l0-1>=0 && s[l0-1] == s[l0])l0--;
while(r0+1 <n && s[r0+1] == s[r0])r0++;
if(l0>=0 && l-l0 >= m)dp[l0][r] = 1;
if(r0<n && r0-r >= m)dp[l][r0] = 1;
if(l0>=0 && r0<n && s[l0] == s[r0] && l-l0+r0-r >= m)dp[l0][r0] = 1;
}
}
if(dp[0][n-1])cout<<"Yes"<<'\n';
else cout<<"No"<<'\n';
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3624kb
input:
BBBRRRRRRGGGB 3
output:
Yes
result:
ok single line: 'Yes'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
BBBRRRRRRGGGB 4
output:
No
result:
ok single line: 'No'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
RRRRGGGRRRRRG 3
output:
Yes
result:
ok single line: 'Yes'
Test #4:
score: 0
Accepted
time: 0ms
memory: 4412kb
input:
GMYCGMRMGYMRMKCBKBMKKBMMKBBKMBMRRMGYKKMBKMYRGGBMRMKKKBRCMKYCCKYGYYKKCKRCYGGKGRBCKMYMRCRGBRRYCCKKRRKRCKMMMGCCGYYKMCRGMKCYBMRRKYYRRKGGRBMCKGBBYYGGGBBYBBRCCMGKKGRGRMRRBRCYGGGKBRKCBYCKMMBRCGKCCYYMMCKGRBYRRGBBCGYKBBMKRBBKGCRBYCKMYKMCKMBRMGGYBKBRBMYGGCKYCMYKBRCCGCYRRRKCKCBKCMCYBKRBKMCCYRBKBGGMGMCBGMBMYCCK 1
output:
Yes
result:
ok single line: 'Yes'
Test #5:
score: 0
Accepted
time: 3ms
memory: 4376kb
input:
KKCCCCCKYYYYYYKKKCRRCCBBBGGMMGCKKBBBBBRCCRRCRRYYCCYYBGGGBKKKBKKKCMKKMCCCGGGCCCCBBBCCKMMMKCCYYBBCCCCCCCCCYYCCCCBMMBRRRBBGGMKKBYMMMYYBBBBYYYYKCCCMMCKKMMMKKGGMBBRRBBBBKKBBBMMMMKKMMMKKKMMYYGMYYYMRRBMMMBGRRGGMMCCGRRBBBGCGGGCBBBCCBGGGGCRKKBBBRRYYYBBBYYKKKYYYBBYYBBBBCCCRKYGGGYYKKKKKKKKKRCCCYKKRRRKKMMMKMMC 2
output:
Yes
result:
ok single line: 'Yes'
Test #6:
score: -100
Wrong Answer
time: 4ms
memory: 4012kb
input:
BYCCCYYBMMMMMMMMGYYYBBBYGBBBGGGKKKKKKGGGKKKBBBBKKBBBYYGGGGYGGGMGGGGMCMCCCMMMYYYYYYYYYYYCCCGGGCCRRRCRRBBBBRCCCCCGYCCCCCCYYCCCGGMGGRRRBCCCBMMMMBRCCCCGYYYGRYYYRRMMMMMRRRRMCBBGGGBBGYYYGGGCCGGGGMMBBGGRRRRGBRRRRYYYYBCCCYCCKKKMMMMCCYGGGYCBBBYYYYCCCCYCCCMMMMYYCBBBBBBBCCCCCGGGGCCCGGGGCCBBBBBGGGGMMMBKKKKMMM 3
output:
No
result:
wrong answer 1st lines differ - expected: 'Yes', found: 'No'