Submission #1000570
Source Code Expand
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstdlib>
#include <ctime>
#include <deque>
using namespace std;
#define P 1000000007
int n, a[210000], tx[210000], ans, now;
bool cmp(int x, int y) {
return a[x] < a[y];
}
int main() {
ans = 1;
scanf("%d", &n);
for (int i = 1; i <= n; i++)
scanf("%d", &a[i]);
for (int i = 1; i <= n; i++)
scanf("%d", &a[i + n]);
for (int i = 1; i <= 2 * n; i++)
tx[i]= i;
sort(tx + 1, tx + 2 * n + 1, cmp);
for (int i = 1; i <= 2 * n; i++) {
if (now > 0 && tx[i] > n)
ans = 1LL * ans * now % P, now -= 1;
else if (now < 0 && tx[i] <= n)
ans = 1LL * ans * (- now) % P, now += 1;
else if (tx[i] <= n)
now += 1;
else
now -= 1;
}
printf("%d\n", ans);
}
Submission Info
Submission Time |
|
Task |
A - 1D Matching |
User |
xyz111 |
Language |
C++14 (GCC 5.4.1) |
Score |
500 |
Code Size |
884 Byte |
Status |
AC |
Exec Time |
51 ms |
Memory |
1920 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:24:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n);
^
./Main.cpp:26:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &a[i]);
^
./Main.cpp:28:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &a[i + n]);
^
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
500 / 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 |
AC |
31 ms |
1152 KB |
001.txt |
AC |
12 ms |
640 KB |
002.txt |
AC |
16 ms |
768 KB |
003.txt |
AC |
18 ms |
896 KB |
004.txt |
AC |
45 ms |
1664 KB |
005.txt |
AC |
51 ms |
1792 KB |
006.txt |
AC |
51 ms |
1792 KB |
007.txt |
AC |
50 ms |
1792 KB |
008.txt |
AC |
51 ms |
1920 KB |
009.txt |
AC |
51 ms |
1792 KB |
010.txt |
AC |
49 ms |
1920 KB |
011.txt |
AC |
50 ms |
1792 KB |
example0.txt |
AC |
2 ms |
256 KB |
example1.txt |
AC |
2 ms |
256 KB |