제출 #444583

#제출 시각아이디문제언어결과실행 시간메모리
444583KiriLL1caDistributing Candies (IOI21_candies)C++17
3 / 100
778 ms14972 KiB
#include <bits/stdc++.h> #define all(X) X.begin(), X.end() #define rall(X) X.rbegin(), X.rend() #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define sz(x) (int)x.size() #define fr first #define sc second #define endl '\n' #define pb push_back #define pf push_front #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx") #pragma GCC target("avx,avx2,fma") #pragma GCC optimize("unroll-loops") using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef long double ld; typedef pair <int, int> pii; const int maxn = 2e5 + 10; struct SegTree_subtask2 { vector <int> t, p; void init () { t.resize(4 * maxn); p.resize(4 * maxn); } void push (int v) { p[2 * v] += p[v]; p[2 * v + 1] += p[v]; p[v] = 0; } void upd (int v, int tl, int tr, int l, int r, int x) { if (tl > r || l > tr) { return; } if (l <= tl && tr <= r) { p[v] += x; return; } push(v); int tm = (tl + tr) >> 1; upd(2 * v, tl, tm, l, r, x); upd(2 * v + 1, tm + 1, tr, l, r, x); } int get (int v, int tl, int tr, int pos) { if (tl == tr) { t[v] += p[v]; p[v] = 0; return t[v]; } else { push(v); int tm = (tl + tr) >> 1; if (pos <= tm) { return get(2 * v, tl, tm, pos); } else { return get(2 * v + 1, tm + 1, tr, pos); } } } }; vector <int> distribute_candies (vector <int> c, vector <int> l, vector <int> r, vector <int> v) { int n = sz(c); int q = sz(l); vector <int> ans (n); bool subtask1 = (n <= 3000); bool subtask2 = true, subtask3 = true; for (int i = 0; i < q; i++) { if (v[i] < 0) { subtask2 = false; } } for (int i = 1; i < n; i++) { if (c[i] != c[0]) { subtask3 = false; } } if (subtask1) { for (int i = 0; i < q; i++) { for (int j = l[i]; j <= r[i]; j++) { if (v[i] > 0) { ans[j] = min(ans[j] + v[i], c[j]); } else { ans[j] = max(0, ans[j] + v[i]); } } } return ans; } if (subtask2) { SegTree_subtask2 st; st.init(); for (int i = 0; i < q; i++) { st.upd(1, 0, n - 1, l[i], r[i], v[i]); } for (int i = 0; i < n; i++) { ans[i] = st.get(1, 0, n - 1, i); if (ans[i] > c[i]) { ans[i] = c[i]; } } return ans; } } /* int32_t main () { int n, q; cin >> n >> q; vector <int> c (n), l (q), r(q), v(q); for (int i = 0; i < n; i++) { cin >> c[i]; } for (int i = 0; i < q; i++) { cin >> l[i] >> r[i] >> v[i]; } vector <int> w = distribute_candies(c, l, r, v); for (auto i : w) { cout << i << " "; } return 0; }*/

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

candies.cpp: In function 'std::vector<int> distribute_candies(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
candies.cpp:81:27: warning: variable 'subtask3' set but not used [-Wunused-but-set-variable]
   81 |     bool subtask2 = true, subtask3 = true;
      |                           ^~~~~~~~
candies.cpp:122:1: warning: control reaches end of non-void function [-Wreturn-type]
  122 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...