Submission #25647828


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)

#include <atcoder/modint>
using mint = atcoder::modint1000000007;

char s[100002]; int n;
// (i, tight)
mint dp[100002][2];

int main() {
  scanf("%s", s);
  n = strlen(s);

  dp[0][1] = 1;

  rep(i, n) rep(tight, 2) {
    mint prv = dp[i][tight];
    if (s[i] == '0') {
      // 0, 0
      dp[i + 1][tight] += prv;
      // 0, 1
      if (!tight) dp[i + 1][false] += prv * 2;
    } else {
      // 0, 0
      dp[i + 1][false] += prv;
      // 0, 1
      dp[i + 1][tight] += prv * 2;
    }
  }

  printf("%d\n", (dp[n][0] + dp[n][1]).val());
}

Submission Info

Submission Time
Task E - Sum Equals Xor
User shino16
Language C++ (GCC 9.2.1)
Score 500
Code Size 639 Byte
Status AC
Exec Time 10 ms
Memory 4628 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:13:8: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   13 |   scanf("%s", s);
      |   ~~~~~^~~~~~~~~

Judge Result

Set Name All Sample
Score / Max Score 500 / 500 0 / 0
Status
AC × 19
AC × 2
Set Name Test Cases
All all_one, one_one, only_one, random_large_01, random_large_010, random_large_02, random_large_03, random_large_04, random_large_05, random_large_06, random_large_07, random_large_08, random_large_09, random_small_01, random_small_02, random_small_03, random_small_04, sample_01, sample_02
Sample sample_01, sample_02
Case Name Status Exec Time Memory
all_one AC 10 ms 4304 KiB
one_one AC 5 ms 4476 KiB
only_one AC 2 ms 4492 KiB
random_large_01 AC 5 ms 4520 KiB
random_large_010 AC 5 ms 4372 KiB
random_large_02 AC 5 ms 4628 KiB
random_large_03 AC 4 ms 4628 KiB
random_large_04 AC 5 ms 4528 KiB
random_large_05 AC 7 ms 4512 KiB
random_large_06 AC 2 ms 4516 KiB
random_large_07 AC 4 ms 4372 KiB
random_large_08 AC 5 ms 4472 KiB
random_large_09 AC 4 ms 4436 KiB
random_small_01 AC 2 ms 4332 KiB
random_small_02 AC 2 ms 4208 KiB
random_small_03 AC 2 ms 4376 KiB
random_small_04 AC 2 ms 4372 KiB
sample_01 AC 2 ms 4368 KiB
sample_02 AC 2 ms 4300 KiB