제출 #272190

#제출 시각아이디문제언어결과실행 시간메모리
272190theStaticMindXOR Sum (info1cup17_xorsum)C++14
0 / 100
180 ms131076 KiB
#include<bits/stdc++.h> #define pb push_back #define ii pair<int,int> #define all(x) (x).begin(),(x).end() #define sz(x) ((int)(x).size()) #define INF 100000000000000000 #define modulo 1000000007 #define mod 998244353 #define int long long int using namespace std; int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); freopen("q.gir", "r", stdin); freopen("q.cik", "w", stdout); int n, ans = 0; cin >> n; vector<int> arr(n); vector<ii> A; for(int i = 0; i < n; i++) cin >> arr[i], A.pb({0, i}); for(int d = 0; d < 50; d++){ int w = (1ll << d); vector<ii> t0, t1; for(auto p : A){ if(arr[p.second] & w) t1.pb({arr[p.second] % (w * 2), p.second}); else t0.pb({arr[p.second] % (w * 2), p.second}); } A = t0; for(auto p : t1) A.pb(p); int p1 = n - 1, p2 = n - 1, p3 = n - 1, cnt = 0; for(auto p : A){ while(p1 >= 0 && A[p1].first + p.first >= w) p1--; while(p2 >= 0 && A[p2].first + p.first >= w * 2) p2--; while(p3 >= 0 && A[p3].first + p.first >= w * 3) p3--; cnt += n - 1 - p3 + p2 - p1; } for(auto p : A){ if((p.first * 2) & w) cnt++; } assert(cnt % 2 == 0); cnt /= 2; if(cnt % 2) ans |= w; } cout << ans; }

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

xorsum.cpp: In function 'int32_t main()':
xorsum.cpp:16:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   16 |  freopen("q.gir", "r", stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
xorsum.cpp:17:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   17 |  freopen("q.cik", "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...