Submission #694941

#TimeUsernameProblemLanguageResultExecution timeMemory
694941Do_you_copySterilizing Spray (JOI15_sterilizing)C++17
100 / 100
183 ms10224 KiB
#include <bits/stdc++.h> #define fi first #define se second #define faster ios_base::sync_with_stdio(0); cin.tie(0); #define pb push_back #define int long long using namespace std; using ll = long long; using pii = pair <int, int>; mt19937_64 Rand(chrono::steady_clock::now().time_since_epoch().count()); const int maxN = 1e5 +1; const int inf = 0x3f3f3f3f; //const int Mod = int n, q, k; ll bit[maxN]; map <int, int> mp; void update(int x, int v){ for (; x <= n; x += x & -x){ bit[x] += v; } } int get(int x){ int res = 0; for (; x; x -= x & -x){ res += bit[x]; } return res; } void Init(){ cin >> n >> q >> k; for (int i = 1; i <= n; ++i){ cin >> mp[i]; update(i, mp[i]); } mp[n + 1] = 0; while (q--){ int s, t, u; cin >> s >> t >> u; if (s == 1){ update(t, u - mp[t]); mp[t] = u; } if (s == 2 && k != 1){ for (auto it = mp.lower_bound(t); it->fi <= u;){ auto it1 = it++; int x = it1->se; it1->se /= k; update(it1->fi, it1->se - x); if (it1->se == 0){ mp.erase(it1); } } } if (s == 3){ cout << get(u) - get(t - 1) << "\n"; } } } #define taskname "test" signed main(){ faster if (fopen(taskname ".inp", "r")){ freopen(taskname ".inp", "r", stdin); freopen(taskname ".out", "w", stdout); } int tt = 1; //cin >> tt; while (tt--){ Init(); } }

Compilation message (stderr)

sterilizing.cpp: In function 'int main()':
sterilizing.cpp:68:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   68 |         freopen(taskname ".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sterilizing.cpp:69:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   69 |         freopen(taskname ".out", "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...