QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#709914 | #9536. Athlete Welcome Ceremony | kinoko777 | WA | 200ms | 251092kb | C++23 | 3.3kb | 2024-11-04 17:22:59 | 2024-11-04 17:23:00 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> p11;
typedef pair<string, int> ps1;
typedef pair<ll, ll> p1111;
#define vv vector
#define pb emplace_back
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fi first
#define se second
#define endl '\n'
#define Endl '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define per(a, b, c) for(int a = b; a <= c; a ++)
#define iper(a, b, c) for(int a = b; a < c; a ++)
#define rep(a, b, c) for(int a = b; a >= c; a --)
#define irep(a, b, c) for(int a = b; a > c; a --)
#define aper(A) for(auto i : A) cout << i << ' ';cout << '\n'
#define lowbit(x) ((x) & (-x))
#define debug(x) cout << (x) << endl
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define PAI acos(-1)
using ll = long long;
mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());
template<class T> void umin(T &x,T y){if(x>y)x=y;}
template<class T> void umax(T &x,T y){if(x<y)x=y;}
const int mod = 1e9 + 7, inf = 1e18;
const double eps = 1e-9;
void add(int &x, int y){x = (x + y) % mod;}
void pre_work(){}
const int N = 310;
int dp[N][N][N][3];
int cnt[N][N][N];
int n, m;
void solve()
{
dp[0][0][0][0] = dp[0][0][0][1] = dp[0][0][0][2] = 1;
cin >> n >> m;
string s;
cin >> s;
s = ' ' + s;
int c = 0;
per(i, 1, n)
c += s[i] == '?';
per(i, 1, n)
per(j, 0, 300)
per(k, 0, 300)
{
if(s[i] == 'a')
dp[i][j][k][0] = (dp[i - 1][j][k][1] + dp[i - 1][j][k][2]) % mod;
else if(s[i] == 'b')
dp[i][j][k][1] = (dp[i - 1][j][k][0] + dp[i - 1][j][k][2]) % mod;
else if(s[i] == 'c')
dp[i][j][k][2] = (dp[i - 1][j][k][0] + dp[i - 1][j][k][1]) % mod;
else if(s[i] == '?')
{
dp[i][j][k][0] = (dp[i - 1][j - 1][k][1] + dp[i - 1][j - 1][k][2]) % mod;
dp[i][j][k][1] = (dp[i - 1][j][k - 1][0] + dp[i - 1][j][k - 1][2]) % mod;
dp[i][j][k][2] = (dp[i - 1][j][k][0] + dp[i - 1][j][k][1]) % mod;
}
}
per(i, 0, 300)
per(j, 0, 300)
if(c - i - j >= 0)
cnt[i][j][c - i - j] = (dp[n][i][j][0] + dp[n][i][j][1] + dp[n][i][j][2]) % mod;
per(i, 0, 300)
per(j, 0, 300)
per(k, 1, 300)
cnt[i][j][k] = (cnt[i][j][k] + cnt[i][j][k - 1]) % mod;
per(i, 0, 300)
per(j, 1, 300)
per(k, 0, 300)
cnt[i][j][k] = (cnt[i][j][k] + cnt[i][j - 1][k]) % mod;
per(i, 1, 300)
per(j, 0, 300)
per(k, 1, 300)
cnt[i][j][k] = (cnt[i][j][k] + cnt[i - 1][j][k]) % mod;
while(m -- )
{
int x, y, z;
cin >> x >> y >> z;
cout << cnt[x][y][z] / 2 << endl;
}
}
signed main()
{
#ifdef LOCAL
freopen("oo.in", "r", stdin);
freopen("oo.out", "w", stdout);
#endif
IOS;
int tt = 1;
// cin >> tt;
pre_work();
while(tt --)
{
solve();
}
return 0;
}
/*
3 1
1 2
*/
详细
Test #1:
score: 100
Accepted
time: 191ms
memory: 242900kb
input:
6 3 a?b??c 2 2 2 1 1 1 1 0 2
output:
3 1 1
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 182ms
memory: 242804kb
input:
6 3 ?????? 2 2 2 2 3 3 3 3 3
output:
30 72 96
result:
ok 3 lines
Test #3:
score: 0
Accepted
time: 175ms
memory: 230612kb
input:
1 1 ? 0 1 1
output:
2
result:
ok single line: '2'
Test #4:
score: -100
Wrong Answer
time: 200ms
memory: 251092kb
input:
10 10 acab?cbaca 0 2 0 1 1 2 4 2 3 1 1 1 3 5 1 0 5 2 2 2 0 1 2 5 4 3 0 1 1 3
output:
0 1 1 1 1 0 0 1 0 1
result:
wrong answer 7th lines differ - expected: '1', found: '0'