Submission #3881883
Source Code Expand
#include"bits/stdc++.h" using namespace std; #define int long long #define rep(i,n) for(int i=0;i<n;i++) const long long mod = 1000000007; const int inf = 1145141919; typedef pair<int, int> P; typedef pair<P, int>PP; typedef pair<int, char>PC; struct edge { int to, cost; }; int a[114514], b[114514]; int npr[114514]; signed main() { int n; cin >> n; rep(i, n)cin >> a[i]; rep(i, n)cin >> b[i]; sort(a, a + n); sort(b, b + n); a[n] = inf; b[n] = inf; npr[0] = 1; rep(i, 112000) { npr[i + 1] = npr[i] * (i + 1); npr[i + 1] %= mod; } int ans = 1; int now = 0; while (now != n) { int np = now; if (a[now] < b[now]) { while (b[now] > a[np]) { np++; } ans *= npr[np - now]; ans %= mod; now = np; } else { while (a[now] > b[np]) { np++; } ans *= npr[np - now]; ans %= mod; now = np; } } cout << ans << endl; }
Submission Info
Submission Time | |
---|---|
Task | A - 1D Matching |
User | Rho17 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 920 Byte |
Status | WA |
Exec Time | 94 ms |
Memory | 2688 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 | 57 ms | 2048 KB |
001.txt | WA | 22 ms | 1408 KB |
002.txt | WA | 30 ms | 1664 KB |
003.txt | WA | 33 ms | 1664 KB |
004.txt | WA | 82 ms | 2560 KB |
005.txt | WA | 93 ms | 2688 KB |
006.txt | WA | 92 ms | 2688 KB |
007.txt | WA | 92 ms | 2688 KB |
008.txt | WA | 92 ms | 2688 KB |
009.txt | WA | 92 ms | 2688 KB |
010.txt | AC | 92 ms | 2688 KB |
011.txt | AC | 94 ms | 2688 KB |
example0.txt | AC | 2 ms | 1152 KB |
example1.txt | AC | 2 ms | 1152 KB |