Submission #22292892


Source Code Expand

Copy
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
#define ll long long
#define ld long double
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());


long long powm(long long a, long long b,long long mod) {
long long res = 1;
while (b > 0) {
    if (b & 1)
        res = res * a %mod;
    a = a * a %mod;
    b >>= 1;
}

return res;
}

ll gcd(ll a, ll b)
{
if (b == 0)
    return a;
return gcd(b, a % b);      
}

const int mod=1e9+7;

signed main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(0);

#ifndef ONLINE_JUDGE
if(fopen("INPUT.txt","r"))
{
freopen("INPUT.txt","r",stdin);
freopen("OUTPUT.txt","w",stdout);
}
#endif
    
    int n;
    cin>>n;
    vector<pair<int,int> >vec;
    int x;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        vec.push_back({x,-1});
    }

    for(int i=0;i<n;i++)
    {
        cin>>x;
        vec.push_back({x,1});
    }
    int tot=0;
    int ans=1;
    sort(vec.begin(),vec.end());
    for(auto i:vec)
    {
        tot+=i.second;
        if(i.second==-1)
        {
            if(tot>0)
            {
                ans*=(tot+1);
                ans%=mod;
            }
        }
    }

    tot=0;
    reverse(vec.begin(),vec.end());
    for(auto i:vec)
    {
        tot+=i.second;
        if(i.second==-1)
        {
            if(tot>0)
            {
                ans*=(tot+1);
                ans%=mod;
            }
        }
    }
    cout<<ans;

}

Submission Info

Submission Time
Task A - 1D Matching
User babayaga
Language C++ (GCC 9.2.1)
Score 500
Code Size 1879 Byte
Status AC
Exec Time 59 ms
Memory 7464 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 2
AC × 14
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 33 ms 5288 KB
001.txt AC 22 ms 4240 KB
002.txt AC 26 ms 4244 KB
003.txt AC 29 ms 5272 KB
004.txt AC 52 ms 7400 KB
005.txt AC 56 ms 7464 KB
006.txt AC 57 ms 7312 KB
007.txt AC 57 ms 7388 KB
008.txt AC 55 ms 7360 KB
009.txt AC 58 ms 7420 KB
010.txt AC 58 ms 7372 KB
011.txt AC 59 ms 7380 KB
example0.txt AC 3 ms 3600 KB
example1.txt AC 3 ms 3604 KB