Submission #1102254


Source Code Expand

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
#include <unordered_set>
#include <complex>
using namespace std;
 
#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
// typedef complex<double> C;
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
int INF = INT_MAX / 2;
double EPS = 1e-10;

template <int M>
struct ModInt {
	int x;
	ModInt() : x(0) {}
	ModInt(int _x) { if ((x = _x % M) < 0) x += M; }
	int operator () () const { return x; }
	ModInt operator - () const { ModInt a = *this; if (a.x) a.x = M - a.x; return a; }
	ModInt& operator += (const ModInt &a) { if ((x += a.x) >= M) x -= M; return *this; }
	ModInt& operator -= (const ModInt &a) { if ((x -= a.x) < M) x += M; return *this; }
	ModInt& operator *= (const ModInt &a) { x = (ll)x * a.x % M; return *this; }
	ModInt operator + (const ModInt &a) const { return ModInt(*this) += a; }
	ModInt operator - (const ModInt &a) const { return ModInt(*this) -= a; }
	ModInt operator * (const ModInt &a) const { return ModInt(*this) *= a; }
};
typedef ModInt<1000000007> mint;

int main() {
	int N; cin >> N;
	vector<i_i> p;
	rep(i, N) {
		int x; scanf("%d", &x);
		p.pb(i_i(x, 1));
	}
	rep(i, N) {
		int x; scanf("%d", &x);
		p.pb(i_i(x, 2));
	}
	sort(p.begin(), p.end());
	int A = 0, B = 0;
	mint ans = 1;
	for (i_i z: p) {
		int x = z.first, t = z.second;
		if (t == 1) {
			if (B) ans *= B, B--;
			else A++;
		}
		if (t == 2) {
			if (A) ans *= A, A--;
			else B++;
		}
	}
	cout << ans() << endl;
}

Submission Info

Submission Time
Task A - 1D Matching
User sugim48
Language C++14 (GCC 5.4.1)
Score 500
Code Size 2098 Byte
Status AC
Exec Time 46 ms
Memory 2420 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:62:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   int x; scanf("%d", &x);
                         ^
./Main.cpp:66:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   int x; scanf("%d", &x);
                         ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 2
AC × 14
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 28 ms 1400 KB
001.txt AC 12 ms 892 KB
002.txt AC 15 ms 892 KB
003.txt AC 18 ms 1400 KB
004.txt AC 42 ms 2420 KB
005.txt AC 46 ms 2420 KB
006.txt AC 46 ms 2420 KB
007.txt AC 45 ms 2420 KB
008.txt AC 46 ms 2420 KB
009.txt AC 46 ms 2420 KB
010.txt AC 45 ms 2420 KB
011.txt AC 45 ms 2420 KB
example0.txt AC 3 ms 256 KB
example1.txt AC 3 ms 256 KB