小样例全对,测试点全错
查看原帖
小样例全对,测试点全错
1013950
__youzimo2014__楼主2024/4/25 20:14

题解 1 的思路

#include <iostream>
using namespace std;
int a[100005], b[100005];
int main(int argc, const char * argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // insert code here...
    int T;
    cin >> T;
    while (T--) {
        int n, k;
        cin >> n >> k;
        for (int i = 1; i <= n; i++) {
            cin >> a[i];
            b[0] ^= a[i];
        }
        for (int i = 1; i <= n; i++) {
            b[i] = b[0] ^ a[i];
        }
        if (k % 2 == 0) {
            for (int i = 1; i <= n; i++) {
                cout << a[i] << ' ';
            }
        } else {
            for (int i = 1; i <= n; i++) {
                cout << b[i] << ' ';
            }
        }
        cout << endl;
    }
    return 0;
}
2024/4/25 20:14
加载中...