Submission #1000577
Source Code Expand
#include <iostream> #include <iomanip> #include <cstdio> #include <cstdlib> #include <algorithm> #include <numeric> #include <random> #include <vector> #include <array> #include <bitset> #include <queue> #include <set> #include <unordered_set> #include <map> #include <unordered_map> using namespace std; using ll = long long; using ull = unsigned long long; constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); } int bsr(int x) { return 31 - __builtin_clz(x); } template<class T> T pow(T x, ll n, T r = 1) { while (n) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; } template<uint MD> struct ModInt { uint v; ModInt() : v{0} {} ModInt(ll v) : v{normS(v%MD+MD)} {} static uint normS(const uint &x) {return (x<MD)?x:x-MD;}; static ModInt make(const uint &x) {ModInt m; m.v = x; return m;} ModInt operator+(const ModInt &r) const {return make(normS(v+r.v));} ModInt operator-(const ModInt &r) const {return make(normS(v+MD-r.v));} ModInt operator*(const ModInt &r) const {return make((ull)v*r.v%MD);} ModInt& operator+=(const ModInt &r) {return *this=*this+r;} ModInt& operator-=(const ModInt &r) {return *this=*this-r;} ModInt& operator*=(const ModInt &r) {return *this=*this*r;} static ModInt inv(const ModInt &x) { return pow(ModInt(x), MD-2); } }; using Mint = ModInt<TEN(9)+7>; const int MN = 1000000; Mint fact[MN]; int main() { fact[0] = 1; for (int i = 1; i < MN; i++) { fact[i] = fact[i-1]*i; } ios::sync_with_stdio(0); cout << setprecision(20); int n; cin >> n; using P = pair<int, int>; vector<P> v; for (int i = 0; i < n; i++) { int x; cin >> x; v.push_back(P(x, 0)); } for (int i = 0; i < n; i++) { int x; cin >> x; v.push_back(P(x, 1)); } Mint ans = 1; sort(v.begin(), v.end()); int co = 0; for (auto p: v) { if (p.second) co++; else co--; ans *= fact[abs(co)]; } cout << ans.v << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - 1D Matching |
User | yosupo |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 2165 Byte |
Status | WA |
Exec Time | 52 ms |
Memory | 6388 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 | 34 ms | 5368 KB |
001.txt | WA | 19 ms | 4860 KB |
002.txt | WA | 22 ms | 4860 KB |
003.txt | WA | 24 ms | 5368 KB |
004.txt | WA | 48 ms | 6388 KB |
005.txt | WA | 51 ms | 6388 KB |
006.txt | WA | 51 ms | 6388 KB |
007.txt | WA | 51 ms | 6388 KB |
008.txt | WA | 52 ms | 6388 KB |
009.txt | WA | 51 ms | 6388 KB |
010.txt | WA | 51 ms | 6388 KB |
011.txt | AC | 51 ms | 6388 KB |
example0.txt | AC | 10 ms | 4224 KB |
example1.txt | AC | 11 ms | 4096 KB |