比赛 26暑假集训模拟赛1 评测结果 AAAAWTTTTT
题目名称 异或加密 最终得分 40
用户昵称 杨蕙宇 运行时间 6.436 s
代码语言 C++ 内存使用 6.43 MiB
提交时间 2026-06-29 09:31:22
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10; 
int n,a[N],b[N],mk[N],ans;
void dfs(int x){
    if(x>n){
        cout<<ans;
    }
    for(int i=1;i<=n;i++){
        if(x==1)ans=(a[x]^b[i]);
        if(mk[i])continue;
        if(x!=1&&(b[i]^a[x])!=ans)continue;
        mk[i]=1;
//        cout<<x<<" "<<i<<" "<<ans<<endl;
        dfs(x+1);
        mk[i]=0;
    }
}
int main(){
    freopen("XORcipher.in","r",stdin); 
    freopen("XORcipher.out","w",stdout); 
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int j=1;j<=n;j++)cin>>b[j];
    dfs(1);
    return 0;
} 
/*
10
1 2 3 4 5 6 10 9 8 7
0 1 2 9 11 12 13 14 15 10

*/