Submission #2288730
Source Code Expand
#include <bits/stdc++.h>
#ifndef LOCAL
#define cerr dolor_sit_amet
#endif
#define mp make_pair
#define sz(x) ((int)((x).size()))
#define X first
#define Y second
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int , int > ipair;
typedef pair < ll , ll > lpair;
const int IINF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const double DINF = numeric_limits<double>::infinity();
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const int DX[] = { 1, 0, -1, 0, 1, -1, 1, -1};
const int DY[] = { 0, 1, 0, -1, 1, -1, -1, 1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll sqr(ll x) { return x*x; } ll sqr(int x) { return (ll)x*x; }
double sqr(double x) { return x*x; } ld sqr(ld x) { return x*x; }
mt19937 mmtw(960172);
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(mmtw) % (y - x + 1) + x; }
// ========================================================================= //
const int N = 300333;
char s[300333];
int main() {
ios::sync_with_stdio(false);
scanf("%s", s + 1);
s[0] = '1';
int n = strlen(s);
s[n] = '1';
++n;
static ll d[N][2][3];
d[1][1][0] = 1;
for (int i = 2; i <= n; ++i) {
if (s[i-1] == '0' || s[i-1] == '?') {
(d[i][0][0] = d[i-1][0][0] + d[i-1][1][0]) %= MOD;
(d[i][0][1] = d[i-1][0][1] + d[i-1][1][1]) %= MOD;
(d[i][0][2] = d[i-1][0][2] + d[i-1][1][2]) %= MOD;
}
if (s[i-1] == '1' || s[i-1] == '?') {
if (i % 2 == 0) {
(d[i][1][0] = d[i-1][0][0]) %= MOD;
(d[i][1][1] = d[i-1][1][0] + d[i-1][1][1] + d[i-1][0][1]) %= MOD;
(d[i][1][2] = d[i-1][1][2] + d[i-1][0][2]) %= MOD;
} else {
(d[i][1][0] = d[i-1][0][0] + d[i-1][1][0]) %= MOD;
(d[i][1][1] = d[i-1][0][1]) %= MOD;
(d[i][1][2] = d[i-1][0][2] + d[i-1][1][1] + d[i-1][1][2]) %= MOD;
}
}
}
cout << d[n][1][2] << "\n";
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | E - Median Replace |
| User | SpyCheese |
| Language | C++14 (GCC 5.4.1) |
| Score | 1600 |
| Code Size | 2207 Byte |
| Status | AC |
| Exec Time | 9 ms |
| Memory | 14592 KiB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:41:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%s", s + 1);
^
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 1600 / 1600 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | s1.txt, s2.txt, s3.txt |
| All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, 43.txt, s1.txt, s2.txt, s3.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 01.txt | AC | 1 ms | 256 KiB |
| 02.txt | AC | 1 ms | 256 KiB |
| 03.txt | AC | 1 ms | 256 KiB |
| 04.txt | AC | 1 ms | 256 KiB |
| 05.txt | AC | 1 ms | 256 KiB |
| 06.txt | AC | 3 ms | 6144 KiB |
| 07.txt | AC | 8 ms | 14592 KiB |
| 08.txt | AC | 3 ms | 4096 KiB |
| 09.txt | AC | 8 ms | 14592 KiB |
| 10.txt | AC | 5 ms | 10368 KiB |
| 11.txt | AC | 7 ms | 14592 KiB |
| 12.txt | AC | 5 ms | 8320 KiB |
| 13.txt | AC | 8 ms | 14592 KiB |
| 14.txt | AC | 1 ms | 384 KiB |
| 15.txt | AC | 8 ms | 14592 KiB |
| 16.txt | AC | 5 ms | 8320 KiB |
| 17.txt | AC | 8 ms | 14592 KiB |
| 18.txt | AC | 5 ms | 8320 KiB |
| 19.txt | AC | 8 ms | 14592 KiB |
| 20.txt | AC | 2 ms | 1792 KiB |
| 21.txt | AC | 8 ms | 14592 KiB |
| 22.txt | AC | 6 ms | 10368 KiB |
| 23.txt | AC | 8 ms | 14592 KiB |
| 24.txt | AC | 3 ms | 4096 KiB |
| 25.txt | AC | 9 ms | 14592 KiB |
| 26.txt | AC | 4 ms | 6144 KiB |
| 27.txt | AC | 8 ms | 14592 KiB |
| 28.txt | AC | 4 ms | 6144 KiB |
| 29.txt | AC | 8 ms | 14592 KiB |
| 30.txt | AC | 8 ms | 14592 KiB |
| 31.txt | AC | 8 ms | 14592 KiB |
| 32.txt | AC | 5 ms | 8320 KiB |
| 33.txt | AC | 8 ms | 14592 KiB |
| 34.txt | AC | 5 ms | 8320 KiB |
| 35.txt | AC | 8 ms | 14592 KiB |
| 36.txt | AC | 6 ms | 10368 KiB |
| 37.txt | AC | 8 ms | 14592 KiB |
| 38.txt | AC | 6 ms | 10368 KiB |
| 39.txt | AC | 9 ms | 14592 KiB |
| 40.txt | AC | 3 ms | 4096 KiB |
| 41.txt | AC | 8 ms | 14592 KiB |
| 42.txt | AC | 3 ms | 6144 KiB |
| 43.txt | AC | 7 ms | 14592 KiB |
| s1.txt | AC | 1 ms | 256 KiB |
| s2.txt | AC | 1 ms | 256 KiB |
| s3.txt | AC | 1 ms | 256 KiB |