Submission #3513371


Source Code Expand

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

inline void fastio(void) {
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
template <typename T>
inline void read(T &x) {
  cin >> x;
}

namespace {
  const int mo = 1e9 + 7;
  inline int add(int x, int y) {
    if((x += y) >= mo) x -= mo;
    return x;
  }
  inline int sub(int x, int y) {
    if((x -= y) < 0) x += mo;
    return x;
  }
  inline int mul(int x, int y) {
    return 1LL * x * y % mo;
  }
  inline int pw(int a, int k) {
    int ans = 1;
    for (; k; k >>= 1, a = mul(a, a))
      if (k & 1) ans = mul(ans, a);
    return ans;
  }
}
const int N = 3e5 + 233;
int n, a[N], b[N], pre = 0, ans = 1;
signed main(void) {
  fastio();
  cin >> n;
  rep (i, n) cin >> a[i];
  rep (i, n) cin >> b[i];
  rep (i, n) {
    ++ pre;
    if (abs(a[i] - b[i]) + abs(a[i - 1] - b[i - 1])
        != abs(a[i] - b[i - 1]) + abs(a[i - 1] - b[i])) {
      ans = 1LL * ans * pre % mo;
      pre = 0;
    }
  }
  if (pre) ans = 1LL * ans * pre % mo;
  cout << ans << "\n";
}

Submission Info

Submission Time
Task A - 1D Matching
User vjudge2
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1096 Byte
Status WA
Exec Time 21 ms
Memory 3072 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 2
AC × 2
WA × 12
Set Name Test Cases
Sample example0.txt, example1.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, example0.txt, example1.txt
Case Name Status Exec Time Memory
000.txt WA 13 ms 2816 KB
001.txt WA 6 ms 2432 KB
002.txt WA 8 ms 2560 KB
003.txt WA 8 ms 2560 KB
004.txt WA 19 ms 3072 KB
005.txt WA 21 ms 3072 KB
006.txt WA 21 ms 3072 KB
007.txt WA 21 ms 3072 KB
008.txt WA 21 ms 3072 KB
009.txt WA 21 ms 3072 KB
010.txt WA 21 ms 3072 KB
011.txt WA 21 ms 3072 KB
example0.txt AC 2 ms 2304 KB
example1.txt AC 1 ms 2304 KB