QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#398424 | #3763. Absolute Difference Equation | SamponYW# | AC ✓ | 118ms | 13720kb | C++14 | 1.5kb | 2024-04-25 11:58:14 | 2024-04-25 11:58:15 |
Judging History
answer
#include <bits/stdc++.h>
#define db double
#define il inline
#define re register
#define ll long long
#define ui unsigned
#define ull ui ll
#define i128 __int128
#define pii pair<int, int>
#define fi first
#define se second
#define eb emplace_back
#define SZ(v) (int)v.size()
#define ALL(v) v.begin(), v.end()
#define mems(v, x) memset(v, x, sizeof(v))
#define memc(a, b) memcpy(a, b, sizeof(a))
#define FOR(i, L, R) for(re int i = (L); i <= (R); ++i)
#define ROF(i, R, L) for(re int i = (R); i >= (L); --i)
#define LS i << 1, l, mid
#define RS i << 1 | 1, mid + 1, r
#define popc(x) __builtin_popcount(x)
using namespace std;
#define N 1000005
#define P 1000000007
il int add(int x, int y) {return x + y < P ? x + y : x + y - P;}
il void addr(int &x, int y) {(x += y) >= P && (x -= P);}
il int qpow(int p, int n = P - 2) {
int s = 1;
while(n) {
if(n & 1) s = 1ll * s * p % P;
p = 1ll * p * p % P, n >>= 1;
}
return s;
}
const int mu = qpow(1e4);
string str;
int n, dp[N][2];
il void WORK() {
n = SZ(str), str = " " + str;
FOR(i, 1, n) dp[i][0] = dp[i][1] = 0;
dp[0][0] = 1;
FOR(i, 1, n) FOR(s, 0, 1) FOR(v, 0, 1)
if(str[i] == '?' || ((str[i] & 1) == v))
addr(dp[i][s ^ (v * (((n - 1) & (i - 1)) == (i - 1)))], dp[i - 1][s]);
cout << dp[n][1] << "\n";
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
while(cin >> str) WORK();
cerr << 1.0 * clock() / CLOCKS_PER_SEC;
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 118ms
memory: 13720kb
input:
1 ????? 1010?1?0 0 1 ? 00 10 ?0 01 11 ?1 0? 1? ?? 000 100 ?00 010 110 ?10 0?0 1?0 ??0 001 101 ?01 011 111 ?11 0?1 1?1 ??1 00? 10? ?0? 01? 11? ?1? 0?? 1?? ??? 0000 1000 ?000 0100 1100 ?100 0?00 1?00 ??00 0010 1010 ?010 0110 1110 ?110 0?10 1?10 ??10 00?0 10?0 ?0?0 01?0 11?0 ?1?0 0??0 1??0 ???0 0001 10...
output:
1 16 2 0 1 1 0 1 1 1 0 1 1 1 2 0 1 1 0 1 1 0 2 2 1 0 1 1 0 1 2 0 2 1 1 2 1 1 2 2 2 4 0 1 1 1 0 1 1 1 2 1 0 1 0 1 1 1 1 2 1 1 2 1 1 2 2 2 4 1 0 1 0 1 1 1 1 2 0 1 1 1 0 1 1 1 2 1 1 2 1 1 2 2 2 4 1 1 2 1 1 2 2 2 4 1 1 2 1 1 2 2 2 4 2 2 4 2 2 4 4 4 8 0 1 1 0 1 1 0 2 2 0 1 1 0 1 1 0 2 2 0 2 2 0 2 2 0 4 4...
result:
ok 162656 lines