比赛 2024暑期C班集训1 评测结果 AAAAAAAAAAAAAAAAAAAA
题目名称 艾姆易艾克斯 最终得分 100
用户昵称 ┭┮﹏┭┮ 运行时间 0.213 s
代码语言 C++ 内存使用 2.86 MiB
提交时间 2024-07-01 08:45:53
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define db double
const int N = 5e5+10;
const ll mod = 1e9+7;

ll read(){
    ll x = 0,f = 1;char c = getchar();
    for(;c < '0' || c > '9';c = getchar())if(c == '-')f = -1;
    for(;c <= '9' && c >= '0';c = getchar())x = (x<<1) + (x<<3) + c-'0';
    return x * f;
}


ll n;
int a[N],b[N],c[N<<1];
bool f[N<<1];
ll ksm(ll x,ll y){
    ll ans = 1;
    while(y){
        if(y & 1)ans = ans * x % mod;
        x = x * x % mod,y >>= 1;
    }return ans;
}
void solve(){
    int same = 0,l = 0,ans = 0;
    n = read();c[++l] = 0;
    for(int i = 1;i <= n;i++)c[++l] = a[i] = read(),c[++l] = a[i]+1;
    for(int i = 1;i <= n;i++)c[++l] = b[i] = read(),c[++l] = b[i]+1;
    sort(c+1,c+1+l);
    l = unique(c+1,c+1+l) - (c+1);
    for(int i = 1;i <= n;i++)a[i] = lower_bound(c+1,c+1+l,a[i]) - c;
    for(int i = 1;i <= n;i++)b[i] = lower_bound(c+1,c+1+l,b[i]) - c;
    
    for(int i = 1;i <= n;i++)
        if(a[i] == b[i])same++,f[a[i]] = 1;
    for(int i = 1;i <= l;i++)
        if(!f[i]){ans = i;break;}
    printf("%d ",c[ans]);
    for(int i = 1;i <= n;i++)
        if(a[i] != b[i] && ans != a[i] && ans != b[i])same++;
    printf("%lld\n",ksm(2,same));
} 
int main(){
    freopen("Mex.in","r",stdin);
    freopen("Mex.out","w",stdout);
    int t = 1;
    while(t--)solve();
    
    return 0;
    
}