Submission #787690

#TimeUsernameProblemLanguageResultExecution timeMemory
787690vjudge1Editor (BOI15_edi)C++17
100 / 100
214 ms72508 KiB
//i_love_aisukiuwu #include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "/home/trucmai/.vim/tools.h" #define debug(x...) cerr << "\e[91m"<<__func__<<":"<<__LINE__<<" [" << #x << "] = ["; _print(x); cerr << "\e[39m" << endl; #else #define debug(x...) #endif void open(){ if(fopen("i.inp","r")){ freopen("i.inp","r",stdin); freopen("o.out","w",stdout); } } #define ll long long #define all(a) (a).begin(), (a).end() #define vi vector<ll> #define pi pair<ll,ll> #define pii pair<ll,pair<ll,ll>> #define fi first #define se second #define gcd __gcd #define mset(a,v) memset(a, v, sizeof(a)) #define endl '\n' #define spc " " const int MN1 = 1e6 + 5,MN2 = 1e4 + 5,LOG = 27; const ll MOD = 1e9 + 7,INF = 1e9; ll n,a[MN1],up[MN1][LOG],lvl[MN1]; void solve(){ cin>>n; for(ll i = 1;i <= n;++i) cin>>a[i]; auto lift=[&](ll u,ll w)->ll{ if(lvl[u] <= w) return u; for(ll i = LOG-1;i >= 0;--i) if(lvl[up[u][i]] > w) u = up[u][i]; return up[u][0]; }; for(ll i = 1;i <= n;++i){ if(a[i] < 0){ lvl[i] = -a[i]; ll tmp = lift(i-1,lvl[i]-1); up[i][0] = lift(tmp-1,lvl[i]-1); //cout<<"DEBUG "<<tmp<<endl; for(ll j = 1;j < LOG;++j) up[i][j] = up[up[i][j-1]][j-1]; } cout<<a[lift(i,0)]<<endl; } } signed main(){ cin.tie(0) -> sync_with_stdio(0); open(); ll t = 1; //cin>>t; while(t--) solve(); #ifdef LOCAL cerr << endl << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"; #endif }

Compilation message (stderr)

edi.cpp: In function 'void open()':
edi.cpp:14:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     freopen("i.inp","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~
edi.cpp:15:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     freopen("o.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...