提出 #2218845


ソースコード 拡げる

#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define ford(i, a, n) for (int i = (int)(n) - 1; i >= (int)(a); --i)
#define fore(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

template<typename T>
inline void setmax(T& a, T b) {
    if (a < b) a = b;
}

template<typename T>
inline void setmin(T& a, T b) {
    if (a > b) a = b;
}

template<typename T, typename S>
istream& operator>> (istream& in, pair<S, T>& p) {
    in >> p.fs >> p.sn;
    return in;
}
template<typename T, typename S>
ostream& operator<< (ostream& out, pair<S, T>& p) {
    out << p.fs << ' ' << p.sn << ' ';
    return out;
}

template<typename T>
istream& operator>> (istream& in, vector<T>& v) {
    for (T& x : v) in >> x;
    return in;
}
template<typename T>
ostream& operator<< (ostream& out, vector<T>& v) {
    for (T& x : v) out << x << ' ';
    return out;
}

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); 
    srand((unsigned)chrono::high_resolution_clock::now().time_since_epoch().count());
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    int ans = 0;
    cin >> a >> b;
    forn(i, 0, 30) {
        //cerr << i << '\n';
        vector<int> res(n);
        forn(j, 0, n) res[j] = b[j] % (1 << (i + 1));
        sort(all(res));
        int total = 0;
        forn(j, 0, n) {
            int x = a[j] % (1 << (i + 1));
            int st = x ? (1 << (i + 1)) - x : 0;
            int fn = st ^ (1 << i);
            //cerr << x << ' ' << st << ' ' << fn << '\n';
            int cnt = (int)(lower_bound(all(res), st) - res.begin()) - (int)(lower_bound(all(res), fn) - res.begin());
            if (cnt < 0) cnt += n;
            total += cnt;
        }
        //cerr << total << '\n';
        if (total % 2)
            ans ^= (1 << i);
    }
    cout << ans << '\n';
}

提出情報

提出日時
問題 D - Two Sequences
ユーザ khadaev
言語 C++14 (GCC 5.4.1)
得点 500
コード長 2481 Byte
結果 AC
実行時間 1656 ms
メモリ 2672 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 500 / 500
結果
AC × 4
AC × 16
セット名 テストケース
Sample example_0, example_1, example_2, example_3
All N100000_0, N100000_1, N150000_0, N150000_1, N200000_0, N200000_1, N200000_ex_0, N200000_ex_1, example_0, example_1, example_2, example_3, rand_0, rand_1, smallrand_0, smallrand_1
ケース名 結果 実行時間 メモリ
N100000_0 AC 746 ms 1408 KiB
N100000_1 AC 745 ms 1408 KiB
N150000_0 AC 1197 ms 2048 KiB
N150000_1 AC 1192 ms 2048 KiB
N200000_0 AC 1656 ms 2672 KiB
N200000_1 AC 1649 ms 2672 KiB
N200000_ex_0 AC 1527 ms 2672 KiB
N200000_ex_1 AC 1532 ms 2672 KiB
example_0 AC 1 ms 256 KiB
example_1 AC 1 ms 256 KiB
example_2 AC 1 ms 256 KiB
example_3 AC 1 ms 256 KiB
rand_0 AC 38 ms 384 KiB
rand_1 AC 83 ms 384 KiB
smallrand_0 AC 1 ms 256 KiB
smallrand_1 AC 1 ms 256 KiB