# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1076668 | 2024-08-26T15:25:50 Z | allin27x | Radio Towers (IOI22_towers) | C++17 | 10 ms | 2260 KB |
#include <bits/stdc++.h> using namespace std; #define int long long vector<int> h; vector<int> lc,rc,a; void init(signed N, std::vector<signed> H){ h.resize(N); for (int i = 0; i < N; i++) h[i] = H[i]; } int dfs(int i, int d){ if (i==-1) return 0; if (lc[i]==-1 && rc[i]==-1) return -a[i]; int lans = dfs(lc[i],d); int rans = dfs(rc[i],d); if (lans < 0 && a[i] - d >= a[lc[i]]) lans = 1; if (rans < 0 && a[i] - d >= a[rc[i]]) rans = 1; if (!lans) return rans; if (!rans) return lans; if (lans < 0 && rans < 0) return max(lans,rans); if (lans < 0) return rans; if (rans < 0) return lans; return lans + rans; } signed max_towers(signed l, signed r, signed d){ int sz = r-l+1; a.assign(sz,0); for (int i=l; i<=r; i++) a[i-l] = h[i]; a.push_back(2e9); stack<int> st; st.push(sz); lc.assign(sz+1,-1); rc.assign(sz+1,-1); for (int i=0; i<sz; i++){ int last = -1; while (a[i] > a[st.top()]) { last=st.top(); st.pop(); } lc[i] = last; rc[st.top()]=i; st.push(i); } for (int i=0; i<=sz; i++) cout<<i<<' '<<lc[i]<<' '<<rc[i]<<'\n'; cout<<'\n'; return dfs(sz,d); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 6 ms | 1644 KB | Execution killed with signal 13 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 344 KB | Possible tampering with the output or unexpected termination of the program |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 344 KB | Possible tampering with the output or unexpected termination of the program |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 10 ms | 2260 KB | Execution killed with signal 13 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 1180 KB | Execution killed with signal 13 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 344 KB | Possible tampering with the output or unexpected termination of the program |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 6 ms | 1644 KB | Execution killed with signal 13 |
2 | Halted | 0 ms | 0 KB | - |