Submission #1000879


Source Code Expand

#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;

int N;
struct node
{
	int x;
	bool flag;
}arr[200001];
bool cmp(node a,node b)
{
	return a.x < b.x;
}
int main()
{
	while(~scanf("%d",&N))
	{
		if(N == 0)
		{
			printf("1\n");
			continue;
		}
		for(int i=1;i<=N;i++)
		{
			scanf("%d",&arr[i].x);
			arr[i].flag = 0;
		}
		for(int i=N+1;i<=2*N;i++)
		{
			scanf("%d",&arr[i].x);
			arr[i].flag = 1;
		}
		sort(arr+1,arr+1+2*N,cmp);
		//for(int i=1;i<=2*N;i++)
		//printf("%d ",arr[i].x);
		int cnt = 0;
		long int ans = 1;
		bool sign = 0;
		for(int i=1;i<=2*N;i++)
		{
			if(!arr[i].flag)
			{
				if(i==1)
				sign = 1;
				cnt++;
				if(i==2*N)
				{
					long int tmp = 1;
					for(int k=1;k<=cnt;k++)
					{
						tmp *= k;
						tmp %= 1000000000 + 7;
					}
					ans *= tmp;
					ans %= 1000000000 + 7;					
				}
			}
			else 
			{
				if(cnt != 0)
				{
					long int tmp = 1;
					if(!sign)
					cnt--;
					for(int k=1;k<=cnt;k++)
					{
						tmp *= k;
						tmp %= 1000000000 + 7;
					}
					ans *= tmp;
					ans %= 1000000000 + 7;
				}
				cnt = 0;
				sign = 0;
			}
		}
		printf("%ld\n",ans);
	}
	return 0;
}

Submission Info

Submission Time
Task A - 1D Matching
User coderLFR
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1235 Byte
Status WA
Exec Time 46 ms
Memory 1664 KB

Compile Error

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

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 28 ms 1152 KB
001.txt WA 11 ms 512 KB
002.txt WA 14 ms 640 KB
003.txt WA 16 ms 640 KB
004.txt WA 41 ms 1536 KB
005.txt WA 46 ms 1664 KB
006.txt WA 46 ms 1664 KB
007.txt WA 46 ms 1664 KB
008.txt WA 46 ms 1664 KB
009.txt WA 46 ms 1664 KB
010.txt AC 45 ms 1664 KB
011.txt AC 45 ms 1664 KB
example0.txt AC 1 ms 128 KB
example1.txt AC 1 ms 128 KB