Submission #3419036


Source Code Expand

#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define pb push_back
#define endl '\n'
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok = true, flag = false;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 222222




int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);

  cin >> n;
  vpll v;
  pll p;
  rep(i, n) {
	cin >> p.first;
	p.second = 0;
	v.pb(p);
  }
  rep(i, n) {
	cin >> p.first;
	p.second = 1;
	v.pb(p);
  }
  sort(all(v));
  tmp = v[0].second;
  cnt = 1;
  ans = 1;
  FOR(i, 1, 2 * n) {
	if (v[i].second == tmp) cnt++;
	else {
	  if (cnt > 0) (ans *= cnt) %= mod;
	  cnt--;
	}
  }
  cout << ans << endl;

  return 0;
}

Submission Info

Submission Time
Task A - 1D Matching
User hide1214
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1711 Byte
Status WA
Exec Time 38 ms
Memory 6000 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 2
AC × 4
WA × 10
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 23 ms 2420 KB
001.txt WA 9 ms 1400 KB
002.txt WA 12 ms 1400 KB
003.txt WA 14 ms 2420 KB
004.txt WA 34 ms 4976 KB
005.txt WA 38 ms 5360 KB
006.txt WA 38 ms 5872 KB
007.txt WA 38 ms 5104 KB
008.txt WA 38 ms 6000 KB
009.txt WA 38 ms 6000 KB
010.txt AC 38 ms 5744 KB
011.txt AC 38 ms 5616 KB
example0.txt AC 1 ms 256 KB
example1.txt AC 1 ms 256 KB