QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#762172#2513. A Color GameSanguineChameleon#WA 168ms12116kbC++201.6kb2024-11-19 14:02:092024-11-19 14:02:17

Judging History

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

  • [2024-11-19 14:02:17]
  • 评测
  • 测评结果:WA
  • 用时:168ms
  • 内存:12116kb
  • [2024-11-19 14:02:09]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define pii pair<int, int>
#define pb push_back
#define debug(x) cerr << #x << "=" << x << endl
#define pq priority_queue
#define inf 0x3f
#define rep(i,a,b) for (int i=a; i < (b); i++)
#define MP make_pair
#define SZ(x) (static_cast<int>(x.size()))
#define MOD 1000000007
#define ALL(x) x.begin(), x.end()
void inc(int &a, int b) {a = (a+b)%MOD;}
void dec(int &a, int b) {a = (a-b+MOD)%MOD;}
int lowbit(int x) {return x&(-x);}

const int MAXN = 555;

int dp[MAXN][MAXN][7];

map<char, int> mp;
int val[MAXN];
string s;
int m;

void solve(int l, int r) {
    if (dp[l][r][0] != -1) return;
    rep(i, 0, 7) dp[l][r][i] = -MOD;
    if (l == r) dp[l][r][val[l]] = 1;
    else {
      bool check = false;
      rep(mid, l, r) {
        rep(i, 0, 7) {
          solve(l, mid), solve(mid + 1, r);
          dp[l][r][i] = max(dp[l][r][i], dp[l][mid][i] + dp[mid + 1][r][i]);
          if (dp[l][r][i] >= m) check = true;
        }
      }
      if (check) rep(i, 0, 7) dp[l][r][i] = max(0, dp[l][r][i]);
    }
    return;
}

int32_t main() {
    ios_base::sync_with_stdio(false);cin.tie(0);
    mp['R'] = 0, mp['G'] = 1, mp['B'] = 2, mp['C'] = 3, mp['M'] = 4, mp['Y'] = 5, mp['K'] = 6;
    cin >> s >> m;
    int n = SZ(s);
    rep(i, 0, n) {
        val[i] = mp[s[i]];
 //       debug(val[i]);
    }
    memset(dp, -1, sizeof(dp));
    solve(0, n - 1);
    rep(i, 0, 7) if (dp[0][n - 1][i] >= m) {
        cout << "Yes";
        return 0;
    } 
    //debug(dp[3][8][0]);
    cout << "No";
}

詳細信息

Test #1:

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

input:

BBBRRRRRRGGGB 3

output:

Yes

result:

ok single line: 'Yes'

Test #2:

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

input:

BBBRRRRRRGGGB 4

output:

No

result:

ok single line: 'No'

Test #3:

score: 0
Accepted
time: 2ms
memory: 12020kb

input:

RRRRGGGRRRRRG 3

output:

Yes

result:

ok single line: 'Yes'

Test #4:

score: 0
Accepted
time: 168ms
memory: 11976kb

input:

GMYCGMRMGYMRMKCBKBMKKBMMKBBKMBMRRMGYKKMBKMYRGGBMRMKKKBRCMKYCCKYGYYKKCKRCYGGKGRBCKMYMRCRGBRRYCCKKRRKRCKMMMGCCGYYKMCRGMKCYBMRRKYYRRKGGRBMCKGBBYYGGGBBYBBRCCMGKKGRGRMRRBRCYGGGKBRKCBYCKMMBRCGKCCYYMMCKGRBYRRGBBCGYKBBMKRBBKGCRBYCKMYKMCKMBRMGGYBKBRBMYGGCKYCMYKBRCCGCYRRRKCKCBKCMCYBKRBKMCCYRBKBGGMGMCBGMBMYCCK 1

output:

Yes

result:

ok single line: 'Yes'

Test #5:

score: 0
Accepted
time: 166ms
memory: 12000kb

input:

KKCCCCCKYYYYYYKKKCRRCCBBBGGMMGCKKBBBBBRCCRRCRRYYCCYYBGGGBKKKBKKKCMKKMCCCGGGCCCCBBBCCKMMMKCCYYBBCCCCCCCCCYYCCCCBMMBRRRBBGGMKKBYMMMYYBBBBYYYYKCCCMMCKKMMMKKGGMBBRRBBBBKKBBBMMMMKKMMMKKKMMYYGMYYYMRRBMMMBGRRGGMMCCGRRBBBGCGGGCBBBCCBGGGGCRKKBBBRRYYYBBBYYKKKYYYBBYYBBBBCCCRKYGGGYYKKKKKKKKKRCCCYKKRRRKKMMMKMMC 2

output:

Yes

result:

ok single line: 'Yes'

Test #6:

score: 0
Accepted
time: 168ms
memory: 12052kb

input:

BYCCCYYBMMMMMMMMGYYYBBBYGBBBGGGKKKKKKGGGKKKBBBBKKBBBYYGGGGYGGGMGGGGMCMCCCMMMYYYYYYYYYYYCCCGGGCCRRRCRRBBBBRCCCCCGYCCCCCCYYCCCGGMGGRRRBCCCBMMMMBRCCCCGYYYGRYYYRRMMMMMRRRRMCBBGGGBBGYYYGGGCCGGGGMMBBGGRRRRGBRRRRYYYYBCCCYCCKKKMMMMCCYGGGYCBBBYYYYCCCCYCCCMMMMYYCBBBBBBBCCCCCGGGGCCCGGGGCCBBBBBGGGGMMMBKKKKMMM 3

output:

Yes

result:

ok single line: 'Yes'

Test #7:

score: 0
Accepted
time: 159ms
memory: 11996kb

input:

RMMMRRRRRRMMMMMMMMMMMMMGGGGBBBBMYYYRRRRRRYYMMGGGGMMMYMMRRRKKKKYYYYYYMMMMMMRRRRRKRKKRKKKKRRRKYYYKKKKYKCCCMMKKKKKMMMCKRRRKKKKRRRRRMMMGGGGGGMMMRCCCCYYYYCCCBBBBCCYCCCCCYYYYRRYYYYRRRRRRRRRRRRRBBBKKKKBRRRRBRRRBBBBBGGGGGGBYGGGGGGYKRBBBBBBRRRCCCCCCCCCRRRRRRRRKCCCCKYYYYKKKMMMMKKKBBMMMMBBBBBBBBKKKKKKRRRR 4

output:

Yes

result:

ok single line: 'Yes'

Test #8:

score: 0
Accepted
time: 158ms
memory: 12108kb

input:

BBKKKKKBBBCCCKKKKKKKKKKKKKCCKGGGGGGGCCCCCCMMMMMMMRRRRRRRRRYYKKKKKKYYYRRRRRKKKKKCBBBBBBBBBBRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRBGGGGGGBBBRRRRMMMMMRMMYYYYYYBBBBMMMMMBBYMMMKGGGGGGGKKKKMGGRRRRRRGGGGRRRRRRRYYYKKKBBBBBBKKKCCCCCCKBBBBBBYBBBBBBBBBBBBBBYYBBBBBBBBBBBYYCCCCCYBBBBBBYRRRRRRYMMMMMMGGGGGGGMMMMMYY 5

output:

Yes

result:

ok single line: 'Yes'

Test #9:

score: 0
Accepted
time: 166ms
memory: 12108kb

input:

BBMMCCCCCCCCCMMMMKKKKKKMMMBCCYMMMMMCYYYYYYYCCCCCMMMMMMMYYYYMMMMCCCYYYYYYYYYCCCCMMMMMMMMCCMMMYCCCCCBBBBBBBBBRRRRRRRRBMMMMMMMGGGGGGGGGGGGGGGGGMMMMMMMMMMGGGGBBBBBBBCCCCCCBBGGCCCCCCMMMCCCCCCCCKKKKKKKCMMMBBCMMMMMMMMCCCBBBKKKKGGGGGGKKKKKBBBBCCCCMMMMMMRRRRRRGGGGRRRRRRRGKKKKKKKKKKKKKKKKKKKKKKMMMMMMMMKKGGGG 6

output:

Yes

result:

ok single line: 'Yes'

Test #10:

score: 0
Accepted
time: 161ms
memory: 12116kb

input:

GGGGGGGGGGGGGGGGRRRRRRRRCCCCYMMMMMMMMCCCCCCCCCCMMMMMMMMMMMMMYYMMMMBBBBBBBBMMMMMYMGGGGGGGGGGGGGGGGGGGGGMMMMMMMMMMMMBBBBBGGGGGGGGGGBBBBBBMMMMKKKKKRRRRRRRRRRRKKKKMMMMMMMYYYYYYYYYYKKKKKKKKKYYYYYBBCKKKGGGGGGGGGGGGKKKKKCCCCMMMMMMMMMMCCCCCBMMMMMMMMMMMBBBBBBBYMMMMMMMMMMMMYYYYYYYYYYYYCGGGGGGGGGGCCCCGG 8

output:

Yes

result:

ok single line: 'Yes'

Test #11:

score: 0
Accepted
time: 154ms
memory: 11976kb

input:

MMMMMMMMMMMMMCCCCCCCCCCCGGGGGGGGGGGGGGGGGGGCCCCCCCCCMMMMKKBBBBBBBBBBBBBBBBKKKKKKKKKKKKKKKKKKKKKKKKBBBBBBBBBBBBBBBBBBBBBBBBRRRRRRRRRRRRRRRMMMMMMMMMMMMMMMCCCCCCCCCCCCCCCCCCCCCCMMMRRRRRRRRRBBBKKKKKKKKKKKKKKKCCCCCCCCCCCCCRRRRRRRRRRRRRRRRRRCCCCCCCCKKKKKKKMKKKKKKKKKKYYYYYYYYYYYYYYYYYYKKKKKKKKKMM 16

output:

Yes

result:

ok single line: 'Yes'

Test #12:

score: 0
Accepted
time: 168ms
memory: 12044kb

input:

GGGGMMMMMMMMMMMMMMMMMMMMMMMMMMRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYMMMMMMMMMMGGGGGGGGGGGGGGGGGKKKKKKKKKKKKKKKKKKKKKKKKKYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBKKKKKKKKKKGGGGGGGGGGGGGGGGGGGGGG 30

output:

Yes

result:

ok single line: 'Yes'

Test #13:

score: -100
Wrong Answer
time: 0ms
memory: 11972kb

input:

RGB 1

output:

No

result:

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