Submission #1006620


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

int N;
const int MAX_N = 1e5;
ll fact [MAX_N + 1];
const ll MOD = 1e9 + 7;

int main()
{
	scanf("%d",&N);
	vector< pair<int,bool> > A(N * 2);
	FOR(i,0,N){
		scanf("%d",&A [i].first);
	}
	FOR(i,0,N){
		scanf("%d",&A [i + N].first);
		A [i].second = true;
	}
	sort(ALL(A));

	fact [1] = 1;
	for(ll i = 2;i <= N;i++){
		(fact [i] = fact [i - 1] * i) %= MOD;
	}

	ll ans = 1,curr = 0,cnt = 0;
	FOR(i,0,N * 2){
		if(A [i].second){
			curr++;
		}
		else{
			curr--;
		}
		cnt++;
		if(curr == 0){
			(ans *= fact [cnt / 2]) %= MOD;
			cnt = 0;
		}
	}

	printf("%lld\n",ans);

	return 0;
}

Submission Info

Submission Time
Task A - 1D Matching
User gigime
Language C++14 (GCC 5.4.1)
Score 0
Code Size 962 Byte
Status WA
Exec Time 44 ms
Memory 2560 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:17:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&N);
                ^
./Main.cpp:20:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&A [i].first);
                           ^
./Main.cpp:23:31: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&A [i + N].first);
                               ^

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 27 ms 1664 KB
001.txt WA 11 ms 768 KB
002.txt WA 15 ms 896 KB
003.txt WA 16 ms 1024 KB
004.txt WA 39 ms 2304 KB
005.txt WA 43 ms 2560 KB
006.txt WA 43 ms 2560 KB
007.txt WA 44 ms 2560 KB
008.txt WA 43 ms 2560 KB
009.txt WA 43 ms 2560 KB
010.txt AC 43 ms 2560 KB
011.txt AC 43 ms 2560 KB
example0.txt AC 3 ms 256 KB
example1.txt AC 3 ms 256 KB