Cod sursa(job #2911943)
Utilizator | Data | 5 iulie 2022 16:20:06 | |
---|---|---|---|
Problema | Stramosi | Scor | 80 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.28 kb |
#include <fstream>
#include <ext/rope>
#define l v[x]
#define b l.size()
__gnu_cxx::rope<int> v[300009];std::ifstream w("stramosi.in");std::ofstream e("stramosi.out");main(){int n,m,x,q; w>>n>>m;for(q=1;q<=n;q++){w>>x;v[q]=v[x]+q;}while(m--){w>>x>>q;e<<(b>q?l[b-q-1]:0)<<'\n';}}