QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#669348#9373. Query on TreewyxqwqWA 46ms3740kbC++142.4kb2024-10-23 18:17:512024-10-23 18:17:52

Judging History

你现在查看的是最新测评结果

  • [2024-10-23 18:17:52]
  • 评测
  • 测评结果:WA
  • 用时:46ms
  • 内存:3740kb
  • [2024-10-23 18:17:51]
  • 提交

answer

#include<bits/stdc++.h>
#define vectorwyx maze
namespace vectorwyx{
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define sml(x,y) (x=min(x,y))
#define big(x,y) (x=max(x,y))
#define ll long long
#define uint unsigned
#define ull unsigned long long
#define umap unordered_map
#define db double
#define fo(i,x,y) for(int i=(x);i<=(y);++i)
#define go(i,x,y) for(int i=(x);i>=(y);--i)
#define ptc putchar
#define gtc getchar
#define emp emplace
#define re return
#define co continue
#define brk break
#define HH (ptc('\n'))
#define bctz __builtin_ctz
#define bclz __builtin_clz
#define bppc __builtin_popcount
using namespace std;
ll seed=chrono::system_clock::now().time_since_epoch().count();
mt19937 rnd(seed);
inline int rm(int x,int y){return (int)(rnd()%(y-x+1ll)+x);}
inline int read(){signed ch=getchar();int x=0,f=1;while(!isdigit(ch)){if(ch==(int)('-'))f=-1;ch=getchar();}while(isdigit(ch)){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}return x*f;}
template<typename T> void out(T *a,int l,int r){fo(i,l,r) cout<<*(a+i)<<' ';puts("");}

const int N=1005;
const ll inf=1e18;
ll a[N];
vector<int> e[N];
int n,dL[N],dR[N],ti,dis[N][N],dod[N];

void dfs1(int x,int fa){
    dL[x]=++ti;dod[ti]=x;
    for(int i:e[x]) if(i!=fa) dfs1(i,x);
    dR[x]=ti;
}

void dfs2(int x,int fa,int Rt){
    for(int i:e[x]) if(i!=fa) dis[Rt][i]=dis[Rt][x]+1,dfs2(i,x,Rt);
}

void solve(){
    cin>>n;int q=read();ti=0;
    assert(n<N);
    fo(i,1,n) e[i].clear();
    fo(i,1,n) cin>>a[i];
    fo(i,2,n){
        int x=read(),y=read();
        e[x].pb(y),e[y].pb(x);
    }
    dfs1(1,0);
    fo(i,1,n) dis[i][i]=0,dfs2(i,0,i);
    while(q--){
        int o=read(),x=read();
        ll ans=-inf;
        if(o==3){
            int v=read();
            fo(i,dL[x],dR[x]){
                int k=dod[i];
                a[k]+=v;
                big(ans,a[k]);
            }
            cout<<ans<<'\n';
            co;
        }
        int k=read(),v=read();
        fo(i,1,n) if((o==1&&dis[x][i]==k)||(o==2&&dis[x][i]<=k)) a[i]+=v,big(ans,a[i]);
        cout<<ans<<'\n';
    }
}

signed main(){
    int T=read();
    while(T--) solve();
    return 0;
}
}
/*
-------------------------------------------------
*/










signed main(){re vectorwyx::main();}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3740kb

input:

1
5 5
1 2 1 3 2
1 2
2 3
2 4
4 5
2 2 1 0
1 2 1 3
3 4 -5
2 5 2 3
3 2 -1

output:

3
6
1
5
4

result:

ok 5 lines

Test #2:

score: -100
Wrong Answer
time: 46ms
memory: 3592kb

input:

10000
3 9
42973045452542 34994498886390 -91733395797555
1 3
1 2
1 1 5 -71952967
3 1 -816873082
1 1 5 -842437577
2 3 7 254550528
3 3 -854082700
2 3 2 699808309
3 3 554885567
1 2 7 595565507
1 3 0 -318374053
3 2
-63158159333100 77264362049163 -99188430131116
1 2
3 2
2 2 4 -305866230
3 1 -549738403
3 5...

output:

-1000000000000000000
42972228579460
-1000000000000000000
42972483129988
-91734812202809
42973182938297
-91733557508933
-1000000000000000000
-91733875882986
77264056182933
77263506444530
7065382376488
7065749360235
7066534912965
-85115611272570
-85114714781312
96492412785032
-20428913156111
-20428197...

result:

wrong answer 1st lines differ - expected: 'GG', found: '-1000000000000000000'