이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define vi vector<int>
#define vp32 vector<p32>
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define MOD %1000000007
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <class T>
using Tree =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//never guess
//never debug without reviewing code
//never try adding ones or substracting them
//only step by step debug when necessay
namespace S{
int n;
vi s, p, w, l;
}
void init(int n, std::vector<int> s, std::vector<int> p, std::vector<int> w, std::vector<int> l) {
S::n = n; S::s = s; S::p = p; S::w = w; S::l = l;
}
long long simulate(int x, int z) {
ll Z = z;
using namespace S;
while(x!=n){
if(Z<s[x]){
Z+=p[x];
x = l[x];
}
else{
Z+=s[x];
x = w[x];
}
}
return Z;
}
#ifdef WIN32
int main()
{
fast_cin();
freopen("input.in", "r", stdin);
freopen("input.out", "w", stdout);
int n,q; cin>>n>>q;
vi s,p,w,l;
for(int i = 0; i<n; i++){
int x; cin>>x;
s.pb(x);
}
for(int i = 0; i<n; i++){
int x; cin>>x;
p.pb(x);
}
for(int i = 0; i<n; i++){
int x; cin>>x;
w.pb(x);
}
for(int i = 0; i<n; i++){
int x; cin>>x;
l.pb(x);
}
init(n,s,p,w,l);
for (size_t i = 0; i < q; i++)
{
int x,z; cin>>x>>z;
cout<<simulate(x,z);
}
return 0;
}
#endif
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |