\(Preface\)
\(Rank38/43\)
\(30pts + 0pts +30pts +0pts = 60pts\)
分好低。。
\(\mathfrak{T1}\ F\)
mad场切题我又没切
枚举。没错,枚举。
但是我枚举的太多了,显然的枚举更少的思路我没发现。我真shab。
思路很简单,考虑到x一定是a_1和某个b_i的异或值,所以x的取值只有n种。
然后就正常枚举正常判断就完了
T1
#include <iostream>
#include <algorithm>
#include <cstring>
#define GMY (520&1314)
#define FBI_OPENTHEDOOR(x) freopen(#x ".in", "r", stdin), freopen(#x ".out", "w", stdout);
#define re register int
#define char_phi signed
#define MARK cout << "###"
#define MARKER "@@@"
#define LMARK "!!!~~~"
#define ZY " qwq "
#define _ ' '
#define Endl cout << '\n'
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
#define N 2005
using namespace std;
inline void Fastio_setup(){ios::sync_with_stdio(false); cin.tie(NULL), cout.tie(NULL), cerr.tie(NULL);}
/*
超 场切的题我没切
这两天老这样
这个题和赛时思路一样
但是赛时sb了枚举了太多的x
*/
int n, x;
char vis[N];
int a[N], b[N], ans[N];
void work(){
cin >> n;
for (re i = 1 ; i <= n ; ++ i)
cin >> a[i];
for (re i = 1 ; i <= n ; ++ i)
cin >> b[i];
char can, cann;
for (re who = 1 ; who <= n ; ++ who){
memset(vis, false, sizeof(vis));
vis[who] = true; cann = true; x = a[1] ^ b[who];
for (re i = 2 ; i <= n ; ++ i){
can = false;
for (re j = 1 ; j <= n ; ++ j)// 判断a[i]和谁对应
if (vis[j] == false and (a[i] ^ b[j]) == x)
{vis[j] = true, can = true; break;}
if (can == false)
{cann = false; break;}
}
if (cann == true)
ans[++ ans[0]] = x;
}
sort(ans+1, ans+ans[0]+1);
cout << ans[0] << '\n';
for (re i = 1 ; i <= ans[0] ; ++ i)
cout << ans[i] << '\n';
}
#define IXINGMY
char_phi main(){
#ifdef IXINGMY
FBI_OPENTHEDOOR(f);
#endif
Fastio_setup();
work();
return GMY;
}