제출 #977240

#제출 시각아이디문제언어결과실행 시간메모리
977240matsakXORanges (eJOI19_xoranges)C++14
100 / 100
113 ms8808 KiB
//__________Lernik in red is rising for me__________// #define _CRT_SECURE_NO_WARNINGS #include <bits/stdc++.h> #include <cstdio> using namespace std; /* #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; */ //__________Dhola ha?__________// #define pb push_back #define YES cout << "YES\n" #define NO cout << "NO\n" #define no_ans cout << -1 <<'\n' #define ll long long #define ppb pop_back #define checking cout << "OK" << endl #define ld long double #define all(v) (v).begin(), (v).end() #define MP make_pair #define PII pair <int, int> #define lower lower_bound #define upper upper_bound #define endl '\n' void setIO(string name = "") { if (!name.empty()) { freopen((name + ".in").c_str(), "r", stdin); freopen((name + ".out").c_str(), "w", stdout); } } void fastIO(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } const ll inf = 1e9, mod = 1e9 + 7, LOG = 32, inf64 = 1e18;; void setPrecision(int x){ if(x == 0){ return; } cout.setf(ios::fixed); cout.precision(x); return; } const int N = 2e5 + 7; int n, q, a[N]; PII tree[4 * N]; struct segtree{ int size = 1; void init(){ while(size < n){ size <<= 1; } build(0, 1, size + 1); } void build(int x, int lx, int rx){ if(rx == lx + 1){ if(lx > n){ tree[x] = MP(0, 0); return; } if(lx & 1){ tree[x] = MP(0, a[lx]); } else{ tree[x] = MP(a[lx], 0); } return; } int m = (lx + rx) / 2; build(2 * x + 1, lx, m); build(2 * x + 2, m, rx); tree[x].first = tree[2 * x + 1].first ^ tree[2 * x + 2].first; tree[x].second = tree[2 * x + 1].second ^ tree[2 * x + 2].second; } void set(int i, int v, int x, int lx, int rx){ if(rx == lx + 1){ if(lx & 1){ tree[x] = MP(0, v); } else{ tree[x] = MP(v, 0); } return; } int m = (lx + rx) / 2; if(i < m){ set(i, v, 2 * x + 1, lx, m); } else{ set(i, v, 2 * x + 2, m, rx); } tree[x].first = tree[2 * x + 1].first ^ tree[2 * x + 2].first; tree[x].second = tree[2 * x + 1].second ^ tree[2 * x + 2].second; } void set(int i, int v){ set(i, v, 0, 1, size + 1); } PII get(int l, int r, int x, int lx, int rx){ if(lx > r || l >= rx){ return MP(0, 0); } if(l <= lx && rx - 1 <= r){ return tree[x]; } int m = (lx + rx) / 2; PII get1 = get(l, r, 2 * x + 1, lx, m), get2 = get(l, r, 2 * x + 2, m, rx); return MP(get1.first ^ get2.first, get1.second ^ get2.second); } PII get(int l, int r){ return get(l, r, 0, 1, size + 1); } }; segtree st; void solve(){ cin >> n >> q; for(int i = 1; i <= n; i++){ cin >> a[i]; } st.init(); while(q--){ int t, i, j; cin >> t >> i >> j; if(t == 1){ st.set(i, j); } else{ if(i % 2 != j % 2){ cout << 0 << endl; } else{ PII s = st.get(i, j); if(i & 1){ cout << s.second << endl; } else{ cout << s.first << endl; } } } /*for(int i = 0; i < 15; i++){ cout << i << ") " << tree[i].first << ' ' << tree[i].second << endl; }*/ } } int main(){ setIO(""); fastIO(); setPrecision(2); int Tests = 1; //cin >> Tests; while(Tests--){ solve(); } return 0; }

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

xoranges.cpp: In function 'void setIO(std::string)':
xoranges.cpp:31:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |   freopen((name + ".in").c_str(), "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
xoranges.cpp:32:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |   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...