제출 #908925

#제출 시각아이디문제언어결과실행 시간메모리
908925borademirtasXOR Sum (info1cup17_xorsum)C++17
0 / 100
1629 ms12880 KiB
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #pragma GCC optimize("O3,unroll-loops") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define ll long long #define vll vector<ll> #define pb push_back #define vp vector<pll> #define tc ll t; cin >> t; for(ll i = 0; i < t; i++){solve(i, t);} #define tc1 solve(1, 1); #define mpvll map<ll, vll> #define vfast vll a(n); for (ll i = 0; i < n; i++) { cin >> a[i]; } #define mpll map<ll,ll> #define pll pair<ll,ll> #define vll2 vector<vector<ll>> dp(n, vector<ll>(m));b #define FIXED(A) cout << fixed; cout.precision(20); cout << A << "\n"; #define mp(A, B) make_pair(A, B) #define all(x) (x).begin(), (x).end() #define rep(i, a, b) for(int i = a; i < (b); ++i) #define sz(x) (int)(x).size() #define big __int128 #define F first #define S second #define ckmin(a,b) a = min(a,b) #define ckmax(a,b) a = max(a,b) template <typename num_t> using indexed_set = tree<num_t, null_type, less<num_t>, rb_tree_tag, tree_order_statistics_node_update>; void setIO(string name) {freopen((name+".in").c_str(),"r",stdin);freopen((name+".out").c_str(),"w",stdout);} ll rd(ll a, ll b){return (a+b-1) / b;} ll isqrt(ll x){ll ans = 0; for(ll k = 1LL << 30; k != 0; k /= 2){if ((ans + k) * (ans + k) <= x) {ans += k;} } return ans; } vll prime(ll x){ll n = x; vll ans; while (n % 2 == 0) {ans.pb(2);n = n/2;} for (int i = 3; i <= sqrt(n); i = i + 2) {while (n % i == 0){ans.pb(i);n = n/i;}}if (n > 2){ans.pb(n);} return ans;} ll binpow(ll a, ll b, ll m) { a %= m; ll res = 1; while (b > 0) { if (b & 1){res = res * a % m;}a = a * a % m; b >>= 1;} return res;} ll lg2(ll n){ll cnt=0;while(n){cnt++;n/=2;}return cnt;} void solve(ll TC, ll TC2) { ll n; cin >> n; vll a(n); for(ll i = 0; i < n; i++){cin >> a[i];} ll ans = 0; for(ll bit =30; bit >= 0; bit--){ ll pw = 1LL<<bit; for(auto &x: a){x%=pw*2;} sort(all(a)); ll cnt = 0; for(ll i = 0; i < n; i++){ ll lb = lower_bound(all(a), pw-a[i]) - a.begin(); ll ub = lower_bound(all(a), 2*pw-a[i]) - a.begin(); //cout << ub << ' ' << lb << " " << a[i] << '\n'; cnt+=ub-lb; lb = lower_bound(all(a), pw*3-a[i]) - a.begin(); //cout << lb << '\n'; cnt += n-lb; if(a[i]*2>=pw&&a[i]*2<pw*2){cnt--;} if(a[i]*2>=pw*3){cnt--;} } //cout << '\n'; cnt/=2; if(cnt&1){ans+=pw;} } cout << ans << '\n'; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); tc1 }

컴파일 시 표준 에러 (stderr) 메시지

xorsum.cpp: In function 'void setIO(std::string)':
xorsum.cpp:31:33: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 | void setIO(string name) {freopen((name+".in").c_str(),"r",stdin);freopen((name+".out").c_str(),"w",stdout);}
      |                          ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
xorsum.cpp:31:73: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 | void setIO(string name) {freopen((name+".in").c_str(),"r",stdin);freopen((name+".out").c_str(),"w",stdout);}
      |                                                                  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...