QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#94945#5576. Advertising ICPCNicolas125841WA 24ms5128kbC++142.6kb2023-04-08 14:06:432023-04-08 14:06:44

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-08 14:06:44]
  • 评测
  • 测评结果:WA
  • 用时:24ms
  • 内存:5128kb
  • [2023-04-08 14:06:43]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll mod = 98244353;


vector<vector<ll>> dp(19683, vector<ll>(2, 0)), dpn(19683, vector<ll>(2, 0));
char mp[8][8];

char conv(int i){
    if(i == 0)
        return 'C';
    else if(i == 1)
        return 'I';
    else
        return 'P';
}

int main(){
    cin.tie(NULL)->sync_with_stdio(false);

    int n, m;
    char tmp;

    cin >> n >> m;

    int m_max = pow(3, m+1);
    int m_jmp = pow(3, m);

    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
            cin >> mp[i][j];

    for(int i = 0; i < m_max; i++){
        int ti = i, iv;
        bool good = true;

        for(int j = 0; j < m; j++){
            iv = ti%3;

            if(mp[0][j] != '?' && conv(iv) != mp[0][j])
                good = false;

            ti /= 3;
        }

        if(mp[1][0] != '?' && conv(ti) != mp[1][0])
            good = false;

        if(good)
            dp[i][0] = 1;
    }

    for(int i = 1; i < n; i++){
        for(int j = ((i == 1) ? 1 : 0); j < m; j++){
            for(int k = 0; k < m_max; k++){
                if(mp[i][j] == '?' || mp[i][j] == 'C'){
                    if(j > 0 && k%3 == 1 && (k/3)%3 == 0 && k/m_jmp == 2){
                        dpn[k/3][1] += dp[k][0] + dp[k][1];
                        dpn[k/3][1] %= mod;
                    }else{
                        dpn[k/3][0] += dp[k][0];
                        dpn[k/3][1] += dp[k][1];
                        dpn[k/3][0] %= mod;
                        dpn[k/3][1] %= mod;
                    }
                }
                
                if(mp[i][j] == '?' || mp[i][j] == 'I'){
                    dpn[k/3 + m_jmp][0] += dp[k][0];
                    dpn[k/3 + m_jmp][1] += dp[k][1];
                    dpn[k/3 + m_jmp][0] %= mod;
                    dpn[k/3 + m_jmp][1] %= mod;
                }

                if(mp[i][j] == '?' || mp[i][j] == 'P'){
                    dpn[k/3 + 2 * m_jmp][0] += dp[k][0];
                    dpn[k/3 + 2 * m_jmp][1] += dp[k][1];
                    dpn[k/3 + 2 * m_jmp][0] %= mod;
                    dpn[k/3 + 2 * m_jmp][1] %= mod;
                }
            }

            for(int k = 0; k < m_max; k++){
                dp[k][0] = dpn[k][0];
                dp[k][1] = dpn[k][1];
                dpn[k][0] = dpn[k][1] = 0;
            }
        }
    }

    ll ans = 0;
    
    for(int i = 0; i < m_max; i++){
        ans += dp[i][1];
        ans %= mod;
    }

    cout << ans << "\n";
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 5ms
memory: 5128kb

input:

3 3
???
?I?
???

output:

243

result:

ok single line: '243'

Test #2:

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

input:

2 2
IC
PC

output:

1

result:

ok single line: '1'

Test #3:

score: -100
Wrong Answer
time: 24ms
memory: 5128kb

input:

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

output:

85077384

result:

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