Submission #3421611
Source Code Expand
#include <iostream>
#include <fstream>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string>
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define REREP(i,n) for(int i = int(n - 1); i >= 0; i--)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define REFOR(i, m, n) for(int i = int(n - 1);i >= int(m);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VD vector<double>
#define VVD vector<vector<double>>
#define VVVD vector<vector<vector<double>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VVVL vector<vector<vector<ll>>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define VVVB vector<vector<vector<bool>>>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVVS vector<vector<vector<string>>>
#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<ll,ll>
#define VPII vector<pair<int,int>>
#define VVPII vector<vector<pair<int,int>>>
#define VVVPII vector<vector<vector<pair<int,int>>>>
#define VPLL vector<pair<ll,ll>>
#define VVPLL vector<vector<pair<ll,ll>>>
#define VVVPLL vector<vector<vector<pair<ll,ll>>>>
const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;
const long double EPS = 1e-10;
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {
o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;
}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {
o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {
o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;
}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {
o << "{" << obj.first << ", " << obj.second << "}"; return o;
}
template <template <class tmp> class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {
o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
void print(void) {
cout << endl;
}
template <class Head> void print(Head&& head) {
cout << head;
print();
}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {
cout << head << " ";
print(forward<Tail>(tail)...);
}
void YN(bool flag) {
cout << ((flag) ? "YES" : "NO") << endl;
}
void Yn(bool flag) {
cout << ((flag) ? "Yes" : "No") << endl;
}
void yn(bool flag) {
cout << ((flag) ? "yes" : "no") << endl;
}
int main() {
ll N; cin >> N;
VL fct(N + 1, 1); FOR(i, 1, N) (fct[i] *= (fct[i - 1] * i)%MOD) %= MOD;
VL a(N), b(N);
REP(i, N) cin >> a[i];
REP(i, N) cin >> b[i];
priority_queue<pair<ll,int>, vector<pair<ll, int>>, greater<pair<ll,int>>> pq;
REP(i, N) pq.push({ a[i],0 });
REP(i, N) pq.push({ b[i],1 });
ll ans = 1;
VI cnt(2, 0);
REP(i,2*N){
int c = pq.top().second;
pq.pop();
if(cnt[(c+1)%2]) (ans *= cnt[(c + 1) % 2]--)%=MOD;
else cnt[c]++;
}
cout << ans << endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
A - 1D Matching |
User |
ningenMe |
Language |
C++14 (GCC 5.4.1) |
Score |
500 |
Code Size |
3711 Byte |
Status |
AC |
Exec Time |
114 ms |
Memory |
8560 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
500 / 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 |
AC |
67 ms |
3828 KB |
001.txt |
AC |
25 ms |
1912 KB |
002.txt |
AC |
34 ms |
2168 KB |
003.txt |
AC |
39 ms |
3188 KB |
004.txt |
AC |
101 ms |
8560 KB |
005.txt |
AC |
113 ms |
8176 KB |
006.txt |
AC |
114 ms |
7664 KB |
007.txt |
AC |
113 ms |
8304 KB |
008.txt |
AC |
113 ms |
7280 KB |
009.txt |
AC |
112 ms |
7280 KB |
010.txt |
AC |
112 ms |
7024 KB |
011.txt |
AC |
112 ms |
8560 KB |
example0.txt |
AC |
1 ms |
256 KB |
example1.txt |
AC |
1 ms |
256 KB |