/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Wrong Answer 1ms 540.0 KiB
#3 Wrong Answer 1ms 540.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
#define SC               scanf
#define PF               printf
#define ull              unsigned long long
#define ld               long double
#define F                first
#define S                second
#define pb               push_back
#define sort_a(a)        sort(a.begin(),a.end());
#define sort_d(a)        sort(a.rbegin(),a.rend());
#define READ(f)          freopen(f, "r", stdin)
#define WRITE(f)         freopen(f, "w", stdout)
#define rev(s)           reverse(s.begin(),s.end())
#define P(ok)            cout << (ok ? "YES\n": "NO\n")
#define __Heart__              ios_base :: sync_with_stdio(false); cin.tie(NULL);
#define ll long long
typedef pair< ll , ll>                   PII;
const int Mx = 100005 ;
const int Mode = 1000000007 ;
ll n , q , type , l , r , pos , value ,  bit[Mx];
void update(ll i , ll value){
   while(i <= n){
    bit[i] |= value ;
    i += i & -i ;
   }
}
ll Ask(ll i) {
    ll sum = 0 ;
    while(i > 0){
        sum |= bit[i] ;
        i -= i & -i ;
    }
    return sum ;
}
void solve()
{
   cin >> n >> q ; ll A[n + 5]  ;
   for(int i = 1 ; i <= n ; i++){
    cin >> A[i] ;
    update(i , A[i]) ;
   }
   while(q--){
    cin >> type ;
    if(type == 1) {
        cin >> pos >> value ;
        A[pos] ^= value ;
       // cout <<"Updating value " <<  A[pos] << endl ;
        update(pos , A[pos]) ;
    }
    else {
        cin >> l >> r ;
        ll cur = Ask(r) | Ask(l - 1) ;
      //  cout <<"Before Shifting " << cur << endl ;
        ll Ans = (cur << (r - l)) % Mode ;
        cout << Ans << endl ;
    }
   }
}
int main()
{
     __Heart__
     int t ; t = 1 ; while(t--) solve() ;
}

Information

Submit By
Type
Submission
Problem
P1183 The Sorcerer’s Subsequence Sum
Language
C++17 (G++ 13.2.0)
Submit At
2025-03-22 02:51:50
Judged At
2025-03-22 02:51:50
Judged By
Score
1
Total Time
1ms
Peak Memory
540.0 KiB