QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#726388 | #9536. Athlete Welcome Ceremony | Willis | WA | 0ms | 13932kb | C++14 | 5.0kb | 2024-11-08 23:35:26 | 2024-11-08 23:35:26 |
Judging History
answer
#ifdef local
#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#endif
// #pragma comment(linker, "/STACK:102400000,102400000")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#ifndef local
#define endl '\n'
#endif
#define pb emplace_back
#define fi first
#define se second
#define rep(i, l, r) for (long long i = l; i <= r; i++)
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define mem(a, x) memset(a, x, sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef pair<int, int> P;
typedef pair<P, int> PP;
const double pi = acos(-1);
typedef __int128_t int128;
const db eps = 1e-9;
std::mt19937_64 rng(time(0));
ll my_random(ll l, ll r)
{
uniform_int_distribution<int> range(l, r);
return range(rng);
}
void __()
{
#ifdef local
system("pause");
#endif
}
ll qp(ll a, ll b, ll mod)
{
ll ans = 1;
while (b)
{
if (b & 1)
ans = ans * a % mod;
a = a * a % mod;
b >>= 1;
}
return ans;
}
const int maxn = 500 + 10;
const ll mod = 1e9 + 7;
int dp[maxn][maxn][maxn][4];
int main()
{
IOS;
int n, q;
cin >> n >> q;
string s;
cin >> s;
if (s[0] == 'a')
dp[1][0][0][1] = 1;
else if (s[0] == 'b')
dp[1][0][0][2] = 1;
else if (s[0] == 'c')
dp[1][0][0][3] = 1;
else
{
if (n == 1 || s[1] == '?')
dp[1][1][0][1] = dp[1][0][1][2] = dp[1][0][0][3] = 1;
else if (s[1] == 'a')
dp[1][0][1][2] = dp[1][0][0][3] = 1;
else if (s[1] == 'b')
dp[1][1][0][1] = dp[1][0][0][3] = 1;
else if (s[1] == 'c')
dp[1][1][0][1] = dp[1][0][1][2] = 1;
}
for (int i = 1; i < n; i++)
{
int curi = i + 1;
for (int j = 0; j <= i; j++)
{
for (int k = 0; k <= i; k++)
{
if (i < n - 1)
{
if (s[i] == 'a')
{
if (s[i + 1] != 'a')
dp[curi][j][k][1] = (dp[curi - 1][j][k][2] + dp[curi - 1][j][k][3]) % mod;
}
else if (s[i] == 'b')
{
if (s[i + 1] != 'b')
dp[curi][j][k][2] = (dp[curi - 1][j][k][1] + dp[curi - 1][j][k][3]) % mod;
}
else if (s[i] == 'c')
{
if (s[i + 1] != 'c')
dp[curi][j][k][3] = (dp[curi - 1][j][k][1] + dp[curi - 1][j][k][2]) % mod;
}
else
{
if (j >= 1)
{
if (s[i + 1] != 'a')
dp[curi][j][k][1] = (dp[curi - 1][j - 1][k][3] + dp[curi - 1][j - 1][k][2]) % mod;
}
if (k >= 1)
{
if (s[i + 1] != 'b')
dp[curi][j][k][2] = (dp[curi - 1][j][k - 1][1] + dp[curi - 1][j][k - 1][3])%mod;
}
if (s[i + 1] != 'c')
dp[curi][j][k][3] = (dp[curi - 1][j][k][1] + dp[curi - 1][j][k][2])%mod;
}
}
else
{
if (s[i] == 'a')
dp[curi][j][k][1] = (dp[curi - 1][j][k][2] + dp[curi - 1][j][k][3]) % mod;
else if (s[i] == 'b')
dp[curi][j][k][2] = (dp[curi - 1][j][k][1] + dp[curi - 1][j][k][3]) % mod;
else if (s[i] == 'c')
dp[curi][j][k][3] = (dp[curi - 1][j][k][1] + dp[curi - 1][j][k][2]) % mod;
else
{
if (j >= 1)
dp[curi][j][k][1] = (dp[curi - 1][j - 1][k][2] + dp[curi - 1][j - 1][k][3]) % mod;
if (k >= 1)
dp[curi][j][k][2] = (dp[curi - 1][j][k - 1][1] + dp[curi - 1][j][k - 1][3]) % mod;
dp[curi][j][k][3] = (dp[curi - 1][j][k][1] + dp[curi - 1][j][k][2]) % mod;
}
}
cout << "i = " << curi << " j = " << j << " k = " << k << " dp = " << dp[curi][j][k][1]<<" "<<dp[curi][j][k][2] <<" "<<dp[curi][j][k][3]<< endl;
}
}
}
__();
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 13932kb
input:
6 3 a?b??c 2 2 2 1 1 1 1 0 2
output:
i = 2 j = 0 k = 0 dp = 0 0 1 i = 2 j = 0 k = 1 dp = 0 0 0 i = 2 j = 1 k = 0 dp = 0 0 0 i = 2 j = 1 k = 1 dp = 0 0 0 i = 3 j = 0 k = 0 dp = 0 1 0 i = 3 j = 0 k = 1 dp = 0 0 0 i = 3 j = 0 k = 2 dp = 0 0 0 i = 3 j = 1 k = 0 dp = 0 0 0 i = 3 j = 1 k = 1 dp = 0 0 0 i = 3 j = 1 k = 2 dp = 0 0 0 i = 3 j = ...
result:
wrong answer 1st lines differ - expected: '3', found: 'i = 2 j = 0 k = 0 dp = 0 0 1'