제출 #704693

#제출 시각아이디문제언어결과실행 시간메모리
704693BidoTeimaSterilizing Spray (JOI15_sterilizing)C++17
0 / 100
5051 ms2904 KiB
/* ID: BidoTeima LANG: C++11 TASK: */ #include <bits/stdc++.h> using namespace std; using ll = long long; void moo(string filename); void ACPLS(string str = "") { if(str=="NOF")return; if(str.size() && str != "IIOT") moo(str); else if(str != "IIOT"){ #ifndef ONLINE_JUDGE freopen("output.txt", "w", stdout); freopen("input.txt", "r", stdin); #endif } ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); } void moo(string fileName){ freopen((fileName+".in").c_str(),"r",stdin); freopen((fileName+".out").c_str(),"w",stdout); } #define tc \ int tttttt/*,subtask*/; \ cin >> tttttt/* >> subtask*/; \ while (tttttt--)/*end */ const int N = 1e5 + 3; ll seg[8 * N], lazy[8 * N]; ll a[N]; void propagate(int node){ assert(lazy[node]); if(lazy[node]!=1){ seg[node] /= lazy[node]; assert(2 * node + 1 < 8 * N); assert(2 * node + 2 < 8 * N); if(lazy[2*node+1]<2e18/lazy[node])lazy[2*node+1]*=lazy[node]; if(lazy[2*node+2]<2e18/lazy[node])lazy[2*node+2]*=lazy[node]; //lazy[2 * node + 1] = lazy[2 * node + 2] = lazy[node]; } lazy[node] = 1; } void build(int l, int r, int node){ lazy[node] = 1; if(l == r){ seg[node] = a[l]; return; } int mid = (l + r) >> 1; build(l, mid, 2 * node + 1); build(mid+1, r, 2 * node + 2); seg[node] = seg[2 * node + 1] + seg[2 * node + 2]; } void upd(int l, int r, int idx, ll value, int node){ //propagate(node); if(idx<l||idx>r) return; if(l == r){ seg[node] = value; return; } int mid = (l + r) >> 1; upd(l, mid, idx, value, 2 * node + 1); upd(mid + 1, r, idx, value, 2 * node + 2); seg[node] = seg[2 * node + 1] + seg[2 * node + 2]; } int query(int l, int r, int ql, int qr, int node){ //propagate(node); if(l > r) return 0; if(l > qr || r < ql) return 0; if(ql <= l && r <= qr) return seg[node]; int mid = (l + r) >> 1; return query(l, mid, ql, qr, 2 * node + 1) + query(mid + 1, r, ql, qr, 2 * node + 2); } void lazy_upd(int l, int r, int ql, int qr, ll value, int node){ if(value==1)return; propagate(node); if(l > qr || r < ql) return; if(l > r) return; if(ql <= l && r <= qr){ if(lazy[node] < 2e18/value){ lazy[node] *= value; } propagate(node); return; } int mid = (l + r) >> 1; lazy_upd(l, mid, ql, qr, value, 2 * node + 1); lazy_upd(mid + 1, r, ql, qr, value, 2 * node + 2); seg[node] = seg[2 * node + 1] + seg[2 * node + 2]; } int main() { ACPLS("IIOT"); int n,q,k; cin>>n>>q>>k; for(int i = 0; i < n; i++) cin>>a[i]; build(0, n - 1, 0); while(q--){ int S; cin>>S; int T, U; cin>>T>>U; if(S == 1){ int A=T,B=U; a[A - 1] = B; upd(0, n - 1, A - 1, B, 0); } if(S == 2){ int l, r; l=T,r=U; --l, --r; for(int i = l; i <= r; i++){ a[i]/=k; upd(0, n - 1, i, a[i], 0); } } if(S == 3){ int l, r; l=T,r=U; --l, --r; cout<<query(0, n - 1, l, r, 0)<<'\n'; } } }

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

sterilizing.cpp: In function 'void ACPLS(std::string)':
sterilizing.cpp:17:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         freopen("output.txt", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
sterilizing.cpp:18:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         freopen("input.txt", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
sterilizing.cpp: In function 'void moo(std::string)':
sterilizing.cpp:26:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     freopen((fileName+".in").c_str(),"r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sterilizing.cpp:27:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     freopen((fileName+".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...