提出 #14557420


ソースコード 拡げる

#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

void solve(){
    int N;
    cin >> N;
    vector<int> a(N);
    REP(i,N) cin >> a[i];
    vector<int> left(N), right(N);
    left[0] = a[0], right[N-1] = a[N-1];
    for(int i=1;i<N;i++) left[i] = left[i-1] ^ a[i];
    for(int i=N-2;i>=0;i--) right[i] = right[i+1] ^ a[i];
    REP(i,N){
        if(i == 0) cout << right[i+1] << " ";
        else if(i == N-1) cout << left[i-1] << " ";
        else cout << (left[i-1] ^ right[i+1]) << " ";
    }
    cout << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    // int T; cin >> T; REP(t,T) solve();
}

提出情報

提出日時
問題 E - Red Scarf
ユーザ Bondo416
言語 C++ (GCC 9.2.1)
得点 500
コード長 1432 Byte
結果 AC
実行時間 45 ms
メモリ 5572 KiB

ジャッジ結果

セット名 All Sample
得点 / 配点 500 / 500 0 / 0
結果
AC × 20
AC × 1
セット名 テストケース
All sample_01.txt, testcase_1.txt, testcase_10.txt, testcase_11.txt, testcase_12.txt, testcase_13.txt, testcase_14.txt, testcase_15.txt, testcase_16.txt, testcase_17.txt, testcase_18.txt, testcase_19.txt, testcase_2.txt, testcase_3.txt, testcase_4.txt, testcase_5.txt, testcase_6.txt, testcase_7.txt, testcase_8.txt, testcase_9.txt
Sample sample_01.txt
ケース名 結果 実行時間 メモリ
sample_01.txt AC 9 ms 3448 KiB
testcase_1.txt AC 2 ms 3452 KiB
testcase_10.txt AC 23 ms 4156 KiB
testcase_11.txt AC 13 ms 3508 KiB
testcase_12.txt AC 5 ms 3632 KiB
testcase_13.txt AC 35 ms 4780 KiB
testcase_14.txt AC 26 ms 3888 KiB
testcase_15.txt AC 30 ms 4612 KiB
testcase_16.txt AC 18 ms 3788 KiB
testcase_17.txt AC 22 ms 4100 KiB
testcase_18.txt AC 41 ms 5304 KiB
testcase_19.txt AC 27 ms 3964 KiB
testcase_2.txt AC 45 ms 5392 KiB
testcase_3.txt AC 35 ms 5480 KiB
testcase_4.txt AC 27 ms 4680 KiB
testcase_5.txt AC 38 ms 5156 KiB
testcase_6.txt AC 29 ms 4300 KiB
testcase_7.txt AC 30 ms 4568 KiB
testcase_8.txt AC 32 ms 4480 KiB
testcase_9.txt AC 45 ms 5572 KiB