Submission #3513313
Source Code Expand
#include <bits/stdc++.h> #define rep(i, n) for (rint i = 1; i <= (n); i ++) #define re0(i, n) for (rint i = 0; i < (int) n; i ++) #define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt) #define rint register int using namespace std; template<typename tp> inline void read(tp &x) { x = 0; char c = getchar(); int f = 0; for (; c < '0' || c > '9'; f |= c == '-', c = getchar()); for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar()); if (f) x = -x; } #define pb push_back #define int long long typedef long long lo; const int N = 3e5 + 233; const int mo = 1e9 + 7; int n, a[N], b[N], fac[N]; inline int sgn(int x) { return x > 0 ? 1 : -1; } signed main(void) { read(n); rep (i, n) read(a[i]); rep (i, n) read(b[i]); sort(a + 1, a + n + 1); sort(b + 1, b + n + 1); fac[0] = 1; rep (i, n) fac[i] = fac[i - 1] * i % mo; int pre = 0; int ans = 1; for (int i = 1; i <= n; i ++) { 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 = ans * fac[pre] % mo; pre = 0; } ++ pre; } ans = ans * fac[pre] % mo; // cout << pre << "\n"; cout << ans << "\n"; }
Submission Info
Submission Time | |
---|---|
Task | A - 1D Matching |
User | vjudge3 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1198 Byte |
Status | WA |
Exec Time | 31 ms |
Memory | 5120 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 500 | ||||||
Status |
|
|
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 | 19 ms | 4864 KB |
001.txt | WA | 8 ms | 4480 KB |
002.txt | WA | 10 ms | 4608 KB |
003.txt | WA | 12 ms | 4608 KB |
004.txt | WA | 28 ms | 4992 KB |
005.txt | WA | 31 ms | 5120 KB |
006.txt | WA | 31 ms | 5120 KB |
007.txt | WA | 31 ms | 5120 KB |
008.txt | WA | 31 ms | 5120 KB |
009.txt | WA | 31 ms | 5120 KB |
010.txt | AC | 31 ms | 5120 KB |
011.txt | AC | 31 ms | 5120 KB |
example0.txt | AC | 2 ms | 4352 KB |
example1.txt | AC | 2 ms | 4352 KB |