QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#753316#5576. Advertising ICPCanyan26WA 491ms90692kbC++171.9kb2024-11-16 12:20:212024-11-16 12:20:23

Judging History

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

  • [2024-11-16 12:20:23]
  • 评测
  • 测评结果:WA
  • 用时:491ms
  • 内存:90692kb
  • [2024-11-16 12:20:21]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    char grid[n][m];
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> grid[i][j];
        }
    }
    map<string, int> dp[n][m];
    if(grid[0][0]=='I' || grid[0][0]=='?')dp[0][0]["I"] = 1;
    if(grid[0][0]=='C' || grid[0][0]=='?')dp[0][0]["C"] = 1;
    if(grid[0][0]=='P' || grid[0][0]=='?')dp[0][0]["P"] = 1;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            if(i==0 && j==0)continue;
            for (auto &mask : dp[i][(j - 1)%m])
            {
                if(grid[i][j]=='I' || grid[i][j]=='?'){
                    string cur = mask.first + "I";
                    if(cur.size() > (m+1))cur = cur.substr(1);
                    dp[i][j][cur] += mask.second;
                }
                if(grid[i][j]=='P'||grid[i][j]=='?'){
                    string cur = mask.first + "P";
                    if(cur.size() > (m+1))cur = cur.substr(1);
                    dp[i][j][cur] += mask.second;
                }
                if (grid[i][j] == 'C' || grid[i][j]=='?')
                {
                    if (mask.first.size() == (m+1) &&
                    mask.first[0] == 'I' && mask.first[1] == 'C' && mask.first[m] == 'P'
                        && j != 0)
                    {
                        continue;
                    }
                    string cur = mask.first + "C";
                    if(cur.size() > (m+1))cur = cur.substr(1);
                    dp[i][j][cur] += mask.second;
                }
            }
        }
    }

    long long ret = 1;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(grid[i][j]=='?')ret *= 3;
        }
    }
    for(auto & i : dp[n-1][m-1]){
        ret -= i.second;
    }
    cout << ret << "\n";
}

详细

Test #1:

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

input:

3 3
???
?I?
???

output:

243

result:

ok single line: '243'

Test #2:

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

input:

2 2
IC
PC

output:

1

result:

ok single line: '1'

Test #3:

score: -100
Wrong Answer
time: 491ms
memory: 90692kb

input:

8 8
????????
????????
????????
????????
????????
????????
????????
????????

output:

8733092899668344401

result:

wrong answer 1st lines differ - expected: '776529021', found: '8733092899668344401'