Submission #471177

#TimeUsernameProblemLanguageResultExecution timeMemory
471177Killer2501Editor (BOI15_edi)C++14
100 / 100
263 ms63032 KiB
#include <bits/stdc++.h> #define ll long long #define ld long double #define pb push_back #define task "tests" #define pll pair<ll, ll> #define pi pair<ll, pll> #define fi first #define se second using namespace std; const ll mod = 1000000000; const ll N = 3e5+55; const int base = 313; ll n, m, t, k, T, ans, q, tong; ll a[N], b[N], d[N], P[N][20]; vector<ll> adj[N], kq; ll pw(ll k, ll n) { ll total = 1; for(; n; n >>= 1) { if(n & 1)total = total * k % mod; k = k * k % mod; } return total; } bool cmp(ll& x, ll& y) { return x > y; } bool check(ll x) { ll total = 0; for(int i = 1; i <= n; i ++) { total += b[i] - mod; ll j = min(n, (total - x) / mod); if(j < 0)continue; if(d[j] - mod * i >= x)return true; } return false; } ll jump(ll x, ll mx) { if(b[x] < mx)return x; for(int i = 19; i >= 0 ; i --)if(b[P[x][i]] >= mx)x = P[x][i]; return P[x][0]; } void sol() { cin >> n; for(int i = 1; i <= n; i ++) { cin >> a[i]; if(a[i] > 0) { cout << a[i] << '\n'; continue; } b[i] = -a[i]; P[i][0] = jump(jump(i-1, b[i])-1, b[i]); for(int j = 1; j < 20 ; j ++)P[i][j] = P[P[i][j-1]][j-1]; cout << a[jump(i, 1)] << '\n'; } } int main() { if(fopen(task".in", "r")) { freopen(task".in", "r", stdin); freopen(task".out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int ntest = 1; //cin >> ntest; while(ntest -- > 0) sol(); }

Compilation message (stderr)

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