Submission #1908476
Source Code Expand
#include <cmath> #include <stack> #include <iostream> #include <algorithm> using namespace std; int n, a[100009], b[100009], p[200009]; bool vis[100009]; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) cin >> b[i]; for (int i = 0; i < 2 * n; i++) p[i] = i; sort(p, p + 2 * n, [](int v1, int v2) { return (v1 < n ? a[v1] : b[v1 - n]) < (v2 < n ? a[v2] : b[v2 - n]); }); int ret = 1, d = 0; stack<int> s; for (int i = 0; i < 2 * n; i++) { d += (p[i] < n ? 1 : -1); if ((d > 0 && p[i] < n) || (d < 0 && p[i] >= n)) { s.push(i); } else { ret = 1LL * ret * (i - s.top() + 1) / 2 % 1000000007; s.pop(); } } cout << ret << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - 1D Matching |
User | square869 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 733 Byte |
Status | WA |
Exec Time | 117 ms |
Memory | 2176 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | WA | 70 ms | 1152 KB |
001.txt | WA | 25 ms | 640 KB |
002.txt | WA | 35 ms | 768 KB |
003.txt | WA | 39 ms | 768 KB |
004.txt | WA | 104 ms | 1664 KB |
005.txt | WA | 117 ms | 1792 KB |
006.txt | WA | 117 ms | 1792 KB |
007.txt | WA | 116 ms | 1792 KB |
008.txt | WA | 117 ms | 1792 KB |
009.txt | WA | 116 ms | 1792 KB |
010.txt | AC | 102 ms | 2176 KB |
011.txt | AC | 116 ms | 1792 KB |
example0.txt | AC | 1 ms | 256 KB |
example1.txt | AC | 1 ms | 256 KB |