結果

問題 No.1216 灯籠流し/Lanterns
ユーザー autumn-eelautumn-eel
提出日時 2020-08-01 19:19:26
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,003 bytes
コンパイル時間 1,834 ms
コンパイル使用メモリ 172,684 KB
実行使用メモリ 15,092 KB
最終ジャッジ日時 2023-09-25 15:12:57
合計ジャッジ時間 20,738 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
9,024 KB
testcase_01 AC 5 ms
9,048 KB
testcase_02 AC 5 ms
9,120 KB
testcase_03 AC 5 ms
9,012 KB
testcase_04 AC 29 ms
11,444 KB
testcase_05 AC 96 ms
14,468 KB
testcase_06 AC 14 ms
9,620 KB
testcase_07 AC 85 ms
13,608 KB
testcase_08 AC 74 ms
12,456 KB
testcase_09 AC 43 ms
11,416 KB
testcase_10 AC 42 ms
11,100 KB
testcase_11 AC 34 ms
11,192 KB
testcase_12 AC 24 ms
10,728 KB
testcase_13 AC 45 ms
12,080 KB
testcase_14 AC 182 ms
12,072 KB
testcase_15 AC 429 ms
12,220 KB
testcase_16 AC 425 ms
14,272 KB
testcase_17 AC 267 ms
12,024 KB
testcase_18 AC 510 ms
11,960 KB
testcase_19 AC 4,099 ms
15,092 KB
testcase_20 AC 1,776 ms
13,640 KB
testcase_21 AC 718 ms
12,944 KB
testcase_22 AC 1,224 ms
13,204 KB
testcase_23 AC 57 ms
14,176 KB
testcase_24 AC 14 ms
9,712 KB
testcase_25 AC 11 ms
9,412 KB
testcase_26 AC 41 ms
11,152 KB
testcase_27 AC 31 ms
11,080 KB
testcase_28 AC 35 ms
11,328 KB
testcase_29 AC 49 ms
12,088 KB
testcase_30 AC 47 ms
11,832 KB
testcase_31 AC 59 ms
12,244 KB
testcase_32 AC 54 ms
12,492 KB
testcase_33 AC 28 ms
10,812 KB
testcase_34 AC 101 ms
14,664 KB
testcase_35 TLE -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll>P;

vector<P>E[60000];
ll d[60000];
int vid[60000],rev[60000];
int cl[60000],cr[60000];
multiset<P>se[60000];

int node_cnt;

void dfs(int v,int p){
	cl[v]=node_cnt;
	vid[v]=node_cnt++;
	rev[vid[v]]=v;
	for(auto u:E[v]){
		if(u.second==p)continue;
		d[u.second]=d[v]+u.first;
		dfs(u.second,v);
	}
	cr[v]=node_cnt;
}

int main(){
	int n,q;cin>>n>>q;
	assert(1<=n&&n<=50000);
	assert(1<=q&&q<=100000);
	rep(i,n-1){
		int a,b;ll c;scanf("%d%d%lld",&a,&b,&c);a--;b--;
		E[a].push_back(P(c,b));
		E[b].push_back(P(c,a));
	}
	dfs(0,-1);
	rep(i,q){
		int ty,v;ll t,l;scanf("%d%d%lld%lld",&ty,&v,&t,&l);v--;
		if(ty==0){
			se[vid[v]].insert(P(t,l));
		}
		else{
			assert(l==0);
			int cnt=0;
			for(int i=cl[v];i<cr[v];i++){
				int u=rev[i];
				ll D=d[u]-d[v];
				for(auto&p:se[i]){
					if(p.first>t-D)break;
					if(D<=p.second)cnt++;
				}
			}
			printf("%d\n",cnt);
		}
	}
}
0