Submission #1320421

#TimeUsernameProblemLanguageResultExecution timeMemory
1320421NgTrung2217Editor (BOI15_edi)C++20
100 / 100
106 ms28248 KiB
#include <bits/stdc++.h> #define taskname "" using namespace std; using ld = long double; using ull = unsigned long long; using ll = long long; const char el = '\n'; const char sp = ' '; const ll inf = 1e18; const int maxN = 3e5 + 5; const int LOG = 20; int n, a[maxN], p[maxN][LOG], h[maxN]; int get_p(int u, int target_h) { if (h[u] <= target_h) return u; for (int i = LOG - 1; i >= 0; --i) { if (h[p[u][i]] > target_h) u = p[u][i]; } return p[u][0]; } int main () { ios_base::sync_with_stdio(0); cin.tie(0); if (fopen(taskname ".inp", "r")) { freopen(taskname ".inp", "r", stdin); freopen(taskname ".out", "w", stdout); } if (!(cin >> n)) return 0; for (int i = 1; i <= n; ++i) { cin >> a[i]; if (a[i] < 0) { h[i] = -a[i]; int z = get_p(i - 1, h[i] - 1); p[i][0] = get_p(z - 1, h[i] - 1); for (int j = 1; j < LOG; ++j) { p[i][j] = p[p[i][j - 1]][j - 1]; } } cout << a[get_p(i, 0)] << el; } return 0; }

Compilation message (stderr)

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