QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#753316 | #5576. Advertising ICPC | anyan26 | WA | 491ms | 90692kb | C++17 | 1.9kb | 2024-11-16 12:20:21 | 2024-11-16 12:20:23 |
Judging History
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'