QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#176798#1790. 机器人游戏hos_lyric100 ✓888ms38728kbC++149.4kb2023-09-12 02:52:422023-09-12 02:52:42

Judging History

你现在查看的是最新测评结果

  • [2023-09-12 02:52:42]
  • 评测
  • 测评结果:100
  • 用时:888ms
  • 内存:38728kb
  • [2023-09-12 02:52:42]
  • 提交

answer

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }

////////////////////////////////////////////////////////////////////////////////
template <unsigned M_> struct ModInt {
  static constexpr unsigned M = M_;
  unsigned x;
  constexpr ModInt() : x(0U) {}
  constexpr ModInt(unsigned x_) : x(x_ % M) {}
  constexpr ModInt(unsigned long long x_) : x(x_ % M) {}
  constexpr ModInt(int x_) : x(((x_ %= static_cast<int>(M)) < 0) ? (x_ + static_cast<int>(M)) : x_) {}
  constexpr ModInt(long long x_) : x(((x_ %= static_cast<long long>(M)) < 0) ? (x_ + static_cast<long long>(M)) : x_) {}
  ModInt &operator+=(const ModInt &a) { x = ((x += a.x) >= M) ? (x - M) : x; return *this; }
  ModInt &operator-=(const ModInt &a) { x = ((x -= a.x) >= M) ? (x + M) : x; return *this; }
  ModInt &operator*=(const ModInt &a) { x = (static_cast<unsigned long long>(x) * a.x) % M; return *this; }
  ModInt &operator/=(const ModInt &a) { return (*this *= a.inv()); }
  ModInt pow(long long e) const {
    if (e < 0) return inv().pow(-e);
    ModInt a = *this, b = 1U; for (; e; e >>= 1) { if (e & 1) b *= a; a *= a; } return b;
  }
  ModInt inv() const {
    unsigned a = M, b = x; int y = 0, z = 1;
    for (; b; ) { const unsigned q = a / b; const unsigned c = a - q * b; a = b; b = c; const int w = y - static_cast<int>(q) * z; y = z; z = w; }
    assert(a == 1U); return ModInt(y);
  }
  ModInt operator+() const { return *this; }
  ModInt operator-() const { ModInt a; a.x = x ? (M - x) : 0U; return a; }
  ModInt operator+(const ModInt &a) const { return (ModInt(*this) += a); }
  ModInt operator-(const ModInt &a) const { return (ModInt(*this) -= a); }
  ModInt operator*(const ModInt &a) const { return (ModInt(*this) *= a); }
  ModInt operator/(const ModInt &a) const { return (ModInt(*this) /= a); }
  template <class T> friend ModInt operator+(T a, const ModInt &b) { return (ModInt(a) += b); }
  template <class T> friend ModInt operator-(T a, const ModInt &b) { return (ModInt(a) -= b); }
  template <class T> friend ModInt operator*(T a, const ModInt &b) { return (ModInt(a) *= b); }
  template <class T> friend ModInt operator/(T a, const ModInt &b) { return (ModInt(a) /= b); }
  explicit operator bool() const { return x; }
  bool operator==(const ModInt &a) const { return (x == a.x); }
  bool operator!=(const ModInt &a) const { return (x != a.x); }
  friend std::ostream &operator<<(std::ostream &os, const ModInt &a) { return os << a.x; }
};
////////////////////////////////////////////////////////////////////////////////

constexpr unsigned MO = 1000000007;
using Mint = ModInt<MO>;


char buf[110];

int N, M;
string S[1010];

Mint pw2[1010], pw3[1010];

int R[1010];
int F[1010][110][2];
using BS = bitset<1010>;
BS G[40][4];
BS H[1 << 16][4];

Mint crt[1 << 17], nxt[1 << 17];

/*
  0-> 0101  
  1-> 0011  
           3
      o    3
       o   3
      oo   2
        o  3
      o o  2
       oo  1
      ooo  1
         o 3
      o  o 1
       o o 2
      oo o 1
        oo 2
      o oo 1
       ooo 1
      oooo 1
*/
int numAll;
BS all;
Mint calc(BS *hs) {
  const BS h1 = (hs[0] & hs[3]) | (hs[1] & hs[2]);
  const BS h2 = (hs[0] | hs[3]) & (hs[1] | hs[2]);
  const int num1 = h1.count();
  const int num2 = (h2 & ~h1).count();
  const int num3 = numAll - num1 - num2;
  return pw2[num2] * pw3[num3];
}

int main() {
  for (; ~scanf("%d%d", &N, &M); ) {
    for (int i = 0; i < M; ++i) {
      scanf("%s", buf);
      S[i] = buf;
    }
    
    pw2[0] = 1;
    pw3[0] = 1;
    for (int i = 1; i <= M; ++i) {
      pw2[i] = pw2[i - 1] * 2;
      pw3[i] = pw3[i - 1] * 3;
    }
    
    for (int i = 0; i < M; ++i) {
      for (int j = 0; j < N; ++j) {
        for (int x = 0; x < 2; ++x) F[i][j][x] = x;
      }
      {
        int j = 0;
        for (const char s : S[i]) {
          switch (s) {
            case 'R': {
              ++j;
            } break;
            case '0': {
              for (int x = 0; x < 2; ++x) F[i][j][x] = 0;
            } break;
            case '1': {
              for (int x = 0; x < 2; ++x) F[i][j][x] = 1;
            } break;
            case '*': {
              for (int x = 0; x < 2; ++x) F[i][j][x] ^= 1;
            } break;
            default: assert(false);
          }
        }
        R[i] = j + 1;
      }
// cerr<<S[i]<<": "<<R[i]<<"; ";for(int j=0;j<N;++j)cerr<<F[i][j][0]<<","<<F[i][j][1]<<" ";cerr<<endl;
    }
    
    numAll = 0;
    all.reset();
    for (int j = 0; j < N; ++j) for (int f = 0; f < 4; ++f) {
      G[j][f].reset();
    }
    vector<vector<int>> iss(N + 1);
    for (int i = 0; i < M; ++i) if (R[i] <= N) {
      iss[R[i]].push_back(i);
    }
    
    Mint ans = 0;
    // fix n: max startpos
    for (int n = N; --n >= 0; ) {
// cerr<<"n = "<<n<<endl;
      // only consider robots with R[i] <= r
      const int r = N - n;
      for (const int i : iss[r]) {
// cerr<<"  add "<<i<<endl;
        ++numAll;
        all.set(i);
        for (int j = 0; j < N; ++j) {
          G[j][F[i][j][0] | F[i][j][1] << 1].set(i);
        }
      }
      if (n <= r) {
        // O*(2^n)
        vector<Mint> prods(1 << n, 1);
        for (int l = 0; l < N; ++l) {
          {
            const int j = l - n;
            if (0 <= j && j < N) {
              for (int f = 0; f < 4; ++f) H[0][f] = G[j][f];
            } else {
              for (int f = 0; f < 4; ++f) H[0][f].reset();
              H[0][2] = all;
            }
          }
          for (int k = 0; k < n; ++k) {
            const int j = l - (n - (k + 1));
            if (0 <= j && j < N) {
              for (int p = 0; p < 1 << k; ++p) {
                for (int f = 0; f < 4; ++f) H[p | 1 << k][f] = H[p][f] | G[j][f];
              }
            } else {
              for (int p = 0; p < 1 << k; ++p) {
                for (int f = 0; f < 4; ++f) H[p | 1 << k][f] = H[p][f];
                H[p | 1 << k][2] |= all;
              }
            }
          }
          for (int p = 0; p < 1 << n; ++p) {
            prods[p] *= calc(H[p]);
          }
        }
        for (int p = 0; p < 1 << n; ++p) {
          ans += (__builtin_parity(p)?-1:+1) * prods[p];
        }
      } else {
        // O*(2^r)
        fill(crt, crt + (1 << (r+1)), 0);
        crt[0] = 1;
        for (int l = 0; l < n; ++l) {
          // include startpos l ?
          fill(nxt, nxt + (1 << (r+1)), 0);
          for (int p = 0; p < 1 << r; ++p) {
            nxt[p << 1    ] += crt[p];
            nxt[p << 1 | 1] -= crt[p];
            nxt[1 << r | p << 1    ] += crt[1 << r | p];
            nxt[1 << r | p << 1 | 1] -= crt[1 << r | p];
          }
          // cell l determined
          for (int f = 0; f < 4; ++f) H[0][f].reset();
          H[0][2] = all;
          for (int k = 0; k < r; ++k) {
            for (int p = 0; p < 1 << k; ++p) {
              for (int f = 0; f < 4; ++f) H[p | 1 << k][f] = H[p][f] | G[k][f];
            }
          }
          for (int p = 0; p < 1 << r; ++p) {
            const Mint res = calc(H[p]);
            nxt[p] *= res;
            nxt[p | 1 << r] *= res;
          }
          copy(nxt, nxt + (1 << (r+1)), crt);
        }
        // cell [n, N) determined
        for (int l = n; l < N; ++l) {
          {
            const int j = l - n;
            if (0 <= j && j < N) {
              for (int f = 0; f < 4; ++f) H[0][f] = G[j][f];
            } else {
              for (int f = 0; f < 4; ++f) H[0][f].reset();
              H[0][2] = all;
            }
          }
          for (int k = 0; k < r; ++k) {
            const int j = l - (n - (k + 1));
            if (0 <= j && j < N) {
              for (int p = 0; p < 1 << k; ++p) {
                for (int f = 0; f < 4; ++f) H[p | 1 << k][f] = H[p][f] | G[j][f];
              }
            } else {
              for (int p = 0; p < 1 << k; ++p) {
                for (int f = 0; f < 4; ++f) H[p | 1 << k][f] = H[p][f];
                H[p | 1 << k][2] |= all;
              }
            }
          }
          for (int p = 0; p < 1 << r; ++p) {
            crt[p] *= calc(H[p]);
            H[p][2] |= all;
            crt[p | 1 << r] *= calc(H[p]);
          }
        }
        for (int p = 0; p < 1 << (r+1); ++p) {
          ans += crt[p];
        }
      }
    }
    printf("%u\n", ans.x);
  }
  return 0;
}

详细

Test #1:

score: 4
Accepted
time: 0ms
memory: 3948kb

input:

1 1
0

output:

3

result:

ok single line: '3'

Test #2:

score: 4
Accepted
time: 1ms
memory: 5912kb

input:

1 1
*

output:

3

result:

ok single line: '3'

Test #3:

score: 4
Accepted
time: 1ms
memory: 5932kb

input:

8 1
RRRR

output:

6561

result:

ok single line: '6561'

Test #4:

score: 4
Accepted
time: 2ms
memory: 5960kb

input:

16 1
1*RR0RRRR1RRR0*R

output:

228047430

result:

ok single line: '228047430'

Test #5:

score: 4
Accepted
time: 856ms
memory: 37612kb

input:

32 1
RRRRRRRRR*R0RRR*R*0RRRRRRRRRR1R*1R*

output:

456286566

result:

ok single line: '456286566'

Test #6:

score: 4
Accepted
time: 888ms
memory: 37620kb

input:

32 1
R11RRR*RR1RR0RRRR1RRRR*0R*RRRR1RRRRR1R*RRR

output:

987597859

result:

ok single line: '987597859'

Test #7:

score: 4
Accepted
time: 2ms
memory: 6080kb

input:

16 5
0RRR0
R*RRR
RRRRRR
RRR1R0R
R1*RRRRRRRR1R1RR1RRR

output:

920870788

result:

ok single line: '920870788'

Test #8:

score: 4
Accepted
time: 865ms
memory: 37736kb

input:

32 5
RRRRRRRR1*RRR
R1R*0R1R***1RRRRRRRRR**RRRRR01*01RR0R*R*RRR
R0RRRRR0RRR0R0RRR0R*RRRR*RR0RR
R1RRRRRRRRR*0RRRR1RR10R*RRR1R11RRRR01*
0R0R0RR0R11RRR0RR0RRR**1*RRR1RRRR0*0RR1R

output:

724757213

result:

ok single line: '724757213'

Test #9:

score: 4
Accepted
time: 867ms
memory: 37524kb

input:

32 5
R1*R*RRRRRRRRRRR01R*R0
1R0RRRR1RR1R***RR0R*RR*RRR*1RR
0
1RRRR0RRRRR1R1RRRR0RRR01R*R01
RRRRR1RRRRRR

output:

339267352

result:

ok single line: '339267352'

Test #10:

score: 4
Accepted
time: 854ms
memory: 37308kb

input:

32 5
RRR*0RR*RR1R1*R10RRRRRR1RRRR1
0RR*RRRRR*R*R0
0RRRR*RRR
0R1RRRRR0RRRRR0RRRR**0RRRRRRRRRRRRRRR
RRRR01RR0R1R0R*R1RR10RRRRRRRR0RR*R0RRR1R

output:

305204884

result:

ok single line: '305204884'

Test #11:

score: 4
Accepted
time: 0ms
memory: 6324kb

input:

16 1000
RRRRRR1RRRRR*RRR
RRR1RR*0RRR1RRR
R0RR11RRR*RRRR0R0R
R1
RRR1RRRRRR1RRR10*
RR*RRR1RRRRRRRR
RR
RRRRRRRRR*R
R*
1RRR*R00*
R0R0R*RRRR
RRRRR000RR
R1R1R1*RRRRRR*
RR1*0*1RRRRRR*RRRRRR
RR
RRRRRRR*R
0RR*RRRRRRRRRRRR10R
RRR*RR1RRRR0RRR*0RRRR
R*1R1RRRR1RRRRRRR
RRRRRRRRR
RRRRR*RRRRR
RR0RR10RR11R
*
0
R1*RR...

output:

278439170

result:

ok single line: '278439170'

Test #12:

score: 4
Accepted
time: 3ms
memory: 7104kb

input:

16 1000
*
RRR0R*0RR
*RRRRRRR0RRR1RRR1RRR
R*RRRRRR11RRRRRRR1R
R
R0R
0RRRRRR1RRRRR
RR**0*R0R
0***R*R*1R
11RRRRRRRRR1RR1
1RR
RR1R
RRRRR0R*R10RRR1RRR1R
RR1R**RR10
1
RRRRRRRR*
R1RRRRRRR0R*RR
*RR*R1*
R0RR
RR1R0RR1*RRRRRRRR1
R
RRR1RRRR1*RRRRR*RRR*
RRR0RRRRR0RR0R1
RRRRRRRRRRRR
R
R0RR1RRR1RR1
**RRRRRR1*RRRR1...

output:

937144102

result:

ok single line: '937144102'

Test #13:

score: 4
Accepted
time: 858ms
memory: 38136kb

input:

32 1000
0
*
0
1
0
0
*
*
0
0
*
1
*
0
1
*
0
0
1
1
1
1
*
0
1
0
0
1
1
*
1
0
0
1
*
0
0
0
*
1
*
0
*
0
*
0
0
*
0
*
*
0
0
1
*
0
*
0
0
1
1
*
0
0
*
1
*
*
*
0
0
1
0
0
*
*
*
0
0
0
0
*
*
*
1
1
*
0
*
0
*
0
*
0
1
*
*
*
*
0
1
0
0
*
0
0
*
0
1
*
0
*
*
1
1
*
0
*
0
1
0
*
1
*
1
1
1
*
0
1
*
*
1
0
1
1
0
0
0
0
0
0
0
1
*
1
...

output:

675565814

result:

ok single line: '675565814'

Test #14:

score: 4
Accepted
time: 873ms
memory: 38704kb

input:

32 1000
*
*
0
*
*
*
0
0
*
0
*
1
*
*
0
0
1
1
1
0
0
*
0
1
0
*
*
0
0
1
1
0
*
1
*
*
0
0
1
0
*
*
0
0
1
0
0
*
*
*
1
1
1
1
*
1
0
1
1
*
1
*
0
1
*
*
*
*
*
0
0
1
1
1
1
0
1
1
0
1
0
*
*
*
*
1
0
1
0
0
1
0
0
1
1
0
1
*
*
1
1
0
0
0
1
*
1
*
0
1
0
0
0
*
0
*
0
0
*
0
0
1
1
0
1
0
0
0
1
*
0
0
*
1
1
0
1
*
*
1
1
1
0
1
1
1
...

output:

969266411

result:

ok single line: '969266411'

Test #15:

score: 4
Accepted
time: 838ms
memory: 38636kb

input:

32 1000
1
0
0
1
0
1
0
*
0
1
1
0
0
1
0
1
0
0
1
0
*
0
*
*
*
0
0
*
0
1
0
0
0
1
0
0
*
0
0
*
*
*
*
0
*
1
*
0
0
1
1
1
1
0
1
*
*
*
0
*
1
*
0
*
1
*
0
0
1
*
*
1
1
*
0
0
1
1
*
*
1
*
0
*
*
*
0
*
0
1
0
*
*
*
0
1
0
1
0
0
1
*
*
0
0
0
0
1
*
1
1
*
*
0
0
1
1
1
0
0
*
*
1
*
1
*
1
*
*
*
0
0
0
1
1
1
0
1
0
*
1
*
1
0
0
1
...

output:

648679786

result:

ok single line: '648679786'

Test #16:

score: 4
Accepted
time: 871ms
memory: 38200kb

input:

32 1000
R1R0RRRRR0R*R1RRRRR**
RRR0R0RR*RRRR
1R*RR0R00RRR
0RRRRRRRRRRR
R1RRRRRR0RR1RRR1
R0R
RRR0RRRRRR**RRR*0RR0
0
R1RR1RRRRR0
RR0*R0RRRRRRR*1RRR
R*1*RRR
RRRRRRRRRR*1R00RR*0*RR00
RRRR1RRRRR
RRR*RRR1RRR*RRR1RRR
R0
1RRRRR*R1RRR*R1
RR1RRRRRR
R1110*RRRRR***RRRR1RRRR
0*R00R1RR0RRR
RRRRR100RR*RRRRR
*
0R1RR...

output:

19340709

result:

ok single line: '19340709'

Test #17:

score: 4
Accepted
time: 870ms
memory: 38460kb

input:

32 1000
RR
1*RRRR1R
R0R
R0R*RRR*RR**R*R*RRR*RR
R
R0RRRRR101RRR
0RRR1RRRRR
0*R*
RRRRRR0RRR1R0RR0R
RRRR01R
1R0RRR0RRRRRR
R0R1R
**1RRRR1
R1R
RR1RRRRRR0RRRRRR
R*R11RRRR***RR*RRRR
RRR1*0RRRR00*R*RRRR1R
RRR
*R*RRR
RRRRRR*RR1RRR1RRRR
RRRRR0RRRRRR
RR11RR
R1RRRRR
R00RR1**RRRRRRRR1RRR
*RR0RR*R1*RRRRR01*0R*
RR...

output:

484551342

result:

ok single line: '484551342'

Test #18:

score: 4
Accepted
time: 851ms
memory: 38268kb

input:

32 1000
1R1RRRR
R0*1RRR1RRRRRRRRRR0R0
0RRR
RRR0RR*R*RRR
01RRRR0RRRRR*R0RRR*R
RR*
*RR1RRRRRRR*R
RR1RRR**RRRR0RRRR*
R**1RRRR0RRR0R1RR1R1RR1
RRRRR*10R
RR*1R1RRRRR1RRR
RR
RRR**1R1RR1
RRR1RR0RR1*1RRRRR*R0R
RRR*
RRRRR11RR
RRRRR1R*RR
R1RRRRR**RR
0R*R10*RR1RRR
11R1R*RRR
1RRRRRR0RRRRRR0**RR
R*1RRR1R0RRRRR
*
...

output:

907694742

result:

ok single line: '907694742'

Test #19:

score: 4
Accepted
time: 856ms
memory: 38200kb

input:

32 1000
RRRRR0RR0RR
RRRR*0RR0RRRRR*R0RR
RR0
0RR
0RRRRRRRRRR0RRRR1R
RRRR
RRR
R1RRRRR*
RR1RRRRR0RR1
0RRR0
RRRR0RRRRRRRRRRR1
RR*RRR1R*R
RRR*R*0RRR
RRRRR
RRRR1RRRR0R0RR*RR
R
R*11R1*RRRR
RR0RRRR0R0RRRR*1R
*RR0RR*R*RRR0
RR*R0*R1R1*RR10RR
R*R
RRRR
0RRRRRRRR
RR001RR
R1RRRRR*
RR**
1RR10R*R
RR1RRRRRRRRRRR*
RR...

output:

424231090

result:

ok single line: '424231090'

Test #20:

score: 4
Accepted
time: 846ms
memory: 38140kb

input:

32 1000
1RRRRRRR*RR*RRR*R
*RR
RRRRRRR1RR01R1*R
*11RRR0RR*RR1
RRRRR*R1RRRRRRR
1RR
**RRRRR
RRRRR1R1RR011R
*R*RRR*R0*0R1*RRRRRRRR
RRRR*RRRRR00RR
RRRRRRR0RRRR0RR1*R1
000RRRRR1RR1R
RR
RRR0RRRRRR00R
RRR1RRRRRRR*00RRRR
RRRRRRR0R11RR0RR1
1RRRRR0R10RRR0RRR
RRRRR0R1*RRR
RRR*RRRRR0RRR*R
RRRRR1R0RR
RRRRR1RRRRRR...

output:

577668630

result:

ok single line: '577668630'

Test #21:

score: 4
Accepted
time: 868ms
memory: 38480kb

input:

32 1000
R0
0
11RR0RR
RRRR0RR010000R
RRRRRR*RRRRR0R*RRR
RRRR
RRRRRRRR
R*RRRR1*0R
R*RR**RRR0
*
RRRR1R1*R1RR0RR01RRR0
RR1R0RR*1*RRRR0R*R*
RRR*0RR*RR00RRR*RRR1*R
1R*R10RRRRRRR11RR1
RRRRRRRRRR0RR
0RR*R1R11RR*R*RRRR*R
RRR
*0R11RRR
1*1R
R1R1R*0RR0RRR*00RR1RR1RR1
R1**RRRR1R*RRRRRRRR
1
**RRRR1RRRRR1RRR1*R**
...

output:

819220679

result:

ok single line: '819220679'

Test #22:

score: 4
Accepted
time: 877ms
memory: 38676kb

input:

32 1000
R0RRR00*R1R0R0R00RRRR
RR*0RRRRRRRRRRRRR*0RRRRRR
RRRRRRRRR
0R10RR1RRRR*
RRRRRRR1RRRRRRRRR*RR1RRRRR00RRRRRRR
R0RRR
RRR1RRRRRR1RRR10*RRRRRR
RRR*RRRRR*RR0RR
RRRR01RRRRR
RRR1RRRRRRRRR1R
0RRR1**RRR1R1R1RRRR*1RR1RRRRRRRR1R0RRRR*RRRR*R
R*RRR0RRRRR
R*RR1RRRRRRRRR*0RR*RR0R*RRRRRR*R1R1RRRR
RR0RR*RRR1R0...

output:

691327935

result:

ok single line: '691327935'

Test #23:

score: 4
Accepted
time: 875ms
memory: 38192kb

input:

32 1000
RRRRRR0*RRRRRRR0RRRRRRRRRRRR
RRR0*1RRRR0RRRR
RRRRR1R
0R0RRR011RRRRRRRR
0RR0RR*RR*RR*RRRRRRRR*
1RR0RRRRRR**0RR1R0**RR0*RRRR*RRR*
RRR00RR1RRR**R*
R01RRRR11R0*0R1*RRRRRRRR*RR0R0RR*00R*RR0R1RRRRRR*
RRR1RRRRRRRR*
RRRRRRRRR*1R*RRR1R0R0*0
R1RR01*RRRRRR
RR11RRR1R1R**RRRR*1R*RRR
R*RRRRRR0RRRRR00R0RRR...

output:

714451377

result:

ok single line: '714451377'

Test #24:

score: 4
Accepted
time: 861ms
memory: 38364kb

input:

32 1000
RRR0R*R0
RRRRRRRR0RRR*R1R*R00R
RRRRRRRRRRR0RR1RRRRRR1RRRR*RRRRRRR00RR
RRRRR
R0RRRRRRRR1
RRRRRRRRRRR1*R*RRRRRRRR
RR*RR*RRR1RRRRRR
*R*1RR0RRRRRRRRR*R1RRRRRRRRRRR1R10R*R1R
1
RRRR
RR11RRRRRRRR1RRRR1RR1RR
RRRRRRRRRR*RRRR*RRRRR*11RR*RRR1RRR10RR
0R1RR0R1R*RRRR*RRRR*1R0RRRRR*RR
RRRRRRRR
*RRRRRRRRRR0...

output:

426645236

result:

ok single line: '426645236'

Test #25:

score: 4
Accepted
time: 865ms
memory: 38728kb

input:

32 1000
1RR1RRRRRR0RRRRRRRRRR
RR1*RRRR1RRRRR*R
RR*RRRR11R
RRR*0*0RR
R0*RRRRRRRRRR0RR0R
R0RRRRRR1R0RRR1R
RRRRRR*R0RRRR00RRRRR0RRRR1RR1RR
RRR*RR*R0*RRRR0RR0RRRRRRR*R10RRRR
RRRR00*
RRRRRRRRRR*R0RR1RRRR
RRRRRR1RRR1*0R*R0*RRRRRRR0RRR*R
10*RRRRRRRR1RR0RRRRRRR0RR0RRR
RRRR*0R1RR
RRRRRR
RR0R1RRRRR*RRRRRRRRRR...

output:

780564072

result:

ok single line: '780564072'

Extra Test:

score: 0
Extra Test Passed