제출 #1183373

#제출 시각아이디문제언어결과실행 시간메모리
1183373SmuggingSpunSnowball (JOI21_ho_t2)C++20
0 / 100
2597 ms1152844 KiB
#include<bits/stdc++.h> #define taskname "B" using namespace std; typedef long long ll; int n, q; namespace sub1{ struct Node{ ll l, r, sum; int lc, rc; Node(){} Node(ll _l, ll _r, ll _sum, int _lc, int _rc) : l(_l), r(_r), sum(_sum), lc(_lc), rc(_rc) {} }; vector<Node>st(1, Node(-2e15, 2e15, 4e15 + 1, -1, -1)); void new_left(int id, ll m){ if(st[id].lc == -1){ st[id].lc = st.size(); st.emplace_back(Node(st[id].l, m, m - st[id].l + 1, -1, -1)); } } void new_right(int id, ll m){ if(st[id].rc == -1){ st[id].rc = st.size(); st.emplace_back(Node(m + 1, st[id].r, st[id].r - m, -1, -1)); } } ll get(int id, ll u, ll v){ if(st[id].r < u || st[id].l > v || st[id].sum == 0){ return 0; } if(u <= st[id].l && v >= st[id].r){ ll ans = st[id].sum; st[id].sum = 0; return ans; } ll m = (st[id].l + st[id].r) >> 1LL; new_left(id, m); new_right(id, m); ll ans = get(st[id].lc, u, v) + get(st[id].rc, u, v); st[id].sum = st[st[id].lc].sum + st[st[id].rc].sum; return ans; } void solve(){ vector<ll>x(n), ans(n, 0); for(ll& v : x){ cin >> v; } for(int _ = 0; _ < q; _++){ ll w; cin >> w; if(w > 0){ for(int i = n - 1; i > -1; x[i--] += w){ ans[i] += get(0, x[i], x[i] + w - 1); } } else{ for(int i = 0; i < n; x[i++] += w){ ans[i] += get(0, x[i] + w, x[i] - 1); } } } for(ll& x : ans){ cout << x << "\n"; } } } namespace sub2{ void solve(){ } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen(taskname".inp", "r")){ freopen(taskname".inp", "r", stdin); } cin >> n >> q; if(max(n, q) <= 2000){ sub1::solve(); } else{ sub2::solve(); } }

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

Main.cpp: In function 'int main()':
Main.cpp:74:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   74 |                 freopen(taskname".inp", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...