Submission #2591964
Source Code Expand
#include<bits/stdc++.h>
// Shrotening
#define fst first
#define snd second
#define pb push_back
// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)
#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)
#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)
//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);
//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);
//debug message
bool debug = true;
#define MSG(s) if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}
//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int> VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;
typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;
typedef std::pair<int,int> PII;
typedef std::vector<PII> VPII;
int N;
VPII v;
const int MOD = 1e9 + 7;
int main() {
std::cin >> N;
v.reserve(2*N);
REP(k, 2) {
REP(i, N) {
int x;
std::cin >> x;
v.emplace_back(std::make_pair(x, k));
}
}
SORT(v);
int cnt = 0;
int ans = 1;
for(auto x: v) {
if(x.snd == 1) {
if(cnt > 0) {
ans = ans * cnt % MOD;
}
--cnt;
} else {
if(cnt < 0) {
ans = ans * (-cnt) % MOD;
}
++cnt;
}
}
std::cout << ans << std::endl;
}
Submission Info
Submission Time |
|
Task |
A - 1D Matching |
User |
b1464296 |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
2056 Byte |
Status |
WA |
Exec Time |
123 ms |
Memory |
1792 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 |
75 ms |
1152 KB |
001.txt |
WA |
27 ms |
640 KB |
002.txt |
WA |
38 ms |
768 KB |
003.txt |
WA |
42 ms |
768 KB |
004.txt |
WA |
110 ms |
1664 KB |
005.txt |
WA |
121 ms |
1792 KB |
006.txt |
WA |
123 ms |
1792 KB |
007.txt |
WA |
121 ms |
1792 KB |
008.txt |
WA |
123 ms |
1792 KB |
009.txt |
WA |
121 ms |
1792 KB |
010.txt |
WA |
122 ms |
1792 KB |
011.txt |
AC |
121 ms |
1792 KB |
example0.txt |
AC |
1 ms |
256 KB |
example1.txt |
AC |
1 ms |
256 KB |