Submission #2012403
Source Code Expand
#include <bits/stdc++.h> #include <vector> #define REP(i,n) for(int i=0;i<n;i++) #define MOD 1000000007 using namespace std; typedef long long ll; ll modkai(ll l){ ll res = 1; for(int i=1;i<=l;i++){ res =res*i%MOD; } return res; } int main(){ ll n; cin>>n; ll a[n],b[n]; REP(i,n){ cin>>a[i]; } REP(i,n){ cin>>b[i]; } sort(a,a+n); sort(b,b+n); ll ac,bc,ai,bi; ac = 0; bc = 0; ai=0; bi=0; ll ans = 1; while(ai<n||bi<n){ if(ai>=n){ bc++; bi++; }else if(bi>= n){ ac++; ai++; }else if(a[ai]<b[bi]){ ac++; ai++; }else{ bc++; bi++; } if(ac==bc){ ans = ans*modkai(ac)%MOD; ac = 0; bc = 0; } } cout<<ans<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - 1D Matching |
User | pue |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 842 Byte |
Status | WA |
Exec Time | 93 ms |
Memory | 1792 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 | 56 ms | 1152 KB |
001.txt | WA | 21 ms | 640 KB |
002.txt | WA | 29 ms | 768 KB |
003.txt | WA | 32 ms | 768 KB |
004.txt | WA | 82 ms | 1664 KB |
005.txt | WA | 92 ms | 1792 KB |
006.txt | WA | 92 ms | 1792 KB |
007.txt | WA | 92 ms | 1792 KB |
008.txt | WA | 92 ms | 1792 KB |
009.txt | WA | 92 ms | 1792 KB |
010.txt | AC | 91 ms | 1792 KB |
011.txt | AC | 93 ms | 1792 KB |
example0.txt | AC | 1 ms | 256 KB |
example1.txt | AC | 1 ms | 256 KB |