제출 #1126276

#제출 시각아이디문제언어결과실행 시간메모리
1126276underwaterkillerwhaleSterilizing Spray (JOI15_sterilizing)C++20
100 / 100
220 ms3924 KiB
//#include"holiday.h" #include <bits/stdc++.h> #define ll long long #define rep(i,m,n) for(int i=(m); i<=(n); i++) #define REB(i,m,n) for(int i=(m); i>=(n); i--) #define pii pair<int,int> #define pll pair<ll,ll> #define MP make_pair #define fs first #define se second #define bit(msk, i) ((msk >> i) & 1) #define iter(id, v) for(auto id : v) #define pb push_back #define SZ(v) (ll)v.size() #define ALL(v) v.begin(),v.end() using namespace std; mt19937_64 rd(chrono :: steady_clock :: now ().time_since_epoch().count()); ll Rand (ll l, ll r) { return uniform_int_distribution<ll> (l, r) (rd); } const int N = 2e5 + 7; const int Mod = 1e9 + 7;///lon const int INF = 1e9 + 7; const ll BASE = 137; const int szBL = 450; int n, Q, K; ll st[N << 2]; int mx[N << 2]; void update (int id, int l, int r, int u, int v) { if (l > v || r < u || mx[id] == 0) return; if (l == r) { st[id] /= K; mx[id] = st[id]; return; } int mid = l + r >> 1; update (id << 1, l, mid, u, v); update (id << 1 | 1, mid + 1, r, u, v); st[id] = st[id << 1] + st[id << 1 | 1]; mx[id] = max(mx[id << 1], mx[id << 1 | 1]); } void Assign (int id, int l, int r, int u, int v) { if (l > u || r < u) return; if (l == r) { st[id] = v; mx[id] = v; return; } int mid = l + r >> 1; Assign (id << 1, l, mid, u, v); Assign (id << 1 | 1, mid + 1, r, u, v); st[id] = st[id << 1] + st[id << 1 | 1]; mx[id] = max(mx[id << 1], mx[id << 1 | 1]); } ll get (int id, int l, int r, int u, int v) { if (l > v || r < u) return 0; if (l >= u && r <= v) return st[id]; int mid = l + r >> 1; return get (id << 1, l, mid, u, v) + get (id << 1 | 1, mid + 1, r, u, v); } void solution() { cin >> n >> Q >> K; rep (i, 1, n) { int X; cin >> X; Assign(1, 1, n, i, X); } rep (i, 1, Q) { int typ, u, v; cin >> typ >> u >> v; if (typ == 1) { Assign(1, 1, n, u, v); } else if (typ == 2) { if (K > 1) update (1, 1, n, u, v); } else { cout << get(1, 1, n, u, v) <<"\n"; } } } #define file(name) freopen(name".inp","r",stdin); \ freopen(name".out","w",stdout); int main () { // file("c"); ios_base :: sync_with_stdio(false); cin.tie(0); cout.tie(0); int num_Test = 1; // cin >> num_Test; while (num_Test--) solution(); } /* no bug challenge +33 2 1 0 1 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...