Submission #1000705
Source Code Expand
class in{struct It{int it;const bool rev;explicit constexpr It(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(It& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const It i,n;public:explicit constexpr in(int n):i(0),n(n<0?0:n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const It& begin(){return i;}const It& end(){return n;}}; #include <bits/stdc++.h> using namespace std; using i64 = long long; const i64 MOD = 1e9 + 7; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; vector<int> a(n), b(n), c(n + 1, -2); for(auto& x : a) cin >> x; for(auto& x : b) cin >> x; sort(a.begin(), a.end()); sort(b.begin(), b.end()); vector<i64> fact(n + 1, 0); fact[0] = fact[1] = 1LL; for(i64 i : in(2, n + 1)) fact[i] = fact[i - 1] * i % MOD; i64 ans = 1LL; for(int _ : in(2)) { vector<bool> used(n, false); for(int i = 0; i < n; ++i) { if(used[i]) continue; auto it = upper_bound(a.begin(), a.end(), b[i]) - a.begin(); int num = it - i; if(num < 0) continue; (ans *= fact[num]) %= MOD; for(int j : in(i, it)) used[j] = true; } swap(a, b); } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - 1D Matching |
User | mio_h1917 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1353 Byte |
Status | WA |
Exec Time | 50 ms |
Memory | 2176 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 | 27 ms | 1408 KB |
001.txt | WA | 11 ms | 640 KB |
002.txt | WA | 15 ms | 896 KB |
003.txt | WA | 16 ms | 896 KB |
004.txt | WA | 39 ms | 2048 KB |
005.txt | WA | 44 ms | 2176 KB |
006.txt | WA | 43 ms | 2176 KB |
007.txt | WA | 43 ms | 2176 KB |
008.txt | WA | 43 ms | 2176 KB |
009.txt | WA | 43 ms | 2176 KB |
010.txt | AC | 40 ms | 2176 KB |
011.txt | AC | 50 ms | 2176 KB |
example0.txt | AC | 2 ms | 256 KB |
example1.txt | AC | 3 ms | 256 KB |