Submission #952539

#TimeUsernameProblemLanguageResultExecution timeMemory
952539guymmkSterilizing Spray (JOI15_sterilizing)C++14
15 / 100
5032 ms8092 KiB
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("O3") #define int long long #define ll long long #define endl "\n" #define vi vector<int> #define vpii vector<pair<int,int> > #define umap unordered_map #define uset unordered_set #define mk make_pair #define pb push_back //#define pop pop_back #define all(x) x.begin(),x.end() #define allr(x) x.rbegin(),x.rend() #define read(x) for (auto& zu: (x)) cin >> zu; #define F first #define S second #define mustawa ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr) #define pii pair<int,int> #define mishari main const int inf=1e9+7; void fa(bool ok){ cout << (ok ? "Yes": "No") << "\n";} void usaco(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } int n; int N=1<<((int)ceil(log2(2e5))); vi tree(2*N); int f(int l,int r,int cl=0,int cr=N-1,int i=1){ if(cl>r||cr<l)return 0; else if(cl>=l&&cr<=r){ return tree[i]; }int md=(cl+cr)/2; return f(l,r,cl,md,i*2)+f(l,r,md+1,cr,i*2+1); } void update(int i,int x){ int j=N+i; tree[j]=x; while(j/=2){ tree[j]=tree[j*2]+tree[j*2+1]; } } void solve() { int q,k; cin>>n>>q>>k; if(k==1) { for (int i = 0; i < n; ++i) { cin >> tree[N + i]; } for (int i = N; --i;) { tree[i] = tree[i * 2] + tree[i * 2 + 1]; } while (q--) { int a, b, c; cin >> a >> b >> c; if (a == 1)update(b - 1, c); else if (a == 3) cout << f(b - 1, c - 1) << endl; } }else{ int a[n]; for(int i=0;i<n;i++)cin>>a[i]; while(q--){ int g,l,r; cin>>g>>l>>r; l--; if(g==1){ a[l]=r; }else if(g==2){ for(int i=l;i<r;i++){ a[i]/=k; } }else{ int ans=0; for(int i=l;i<r;i++){ ans+=a[i]; }cout<<ans<<endl; } } } } signed mishari() { mustawa; //usaco(""); int t = 1; //cin>>t; while (t--)solve(); }

Compilation message (stderr)

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