結果
問題 | No.2618 除霊 |
ユーザー | Rubikun |
提出日時 | 2024-01-26 21:51:50 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 224 ms / 2,000 ms |
コード長 | 1,579 bytes |
コンパイル時間 | 2,141 ms |
コンパイル使用メモリ | 205,112 KB |
実行使用メモリ | 33,608 KB |
最終ジャッジ日時 | 2024-01-26 21:52:08 |
合計ジャッジ時間 | 11,378 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 8 ms
19,256 KB |
testcase_01 | AC | 7 ms
19,256 KB |
testcase_02 | AC | 7 ms
19,256 KB |
testcase_03 | AC | 7 ms
19,256 KB |
testcase_04 | AC | 6 ms
19,256 KB |
testcase_05 | AC | 7 ms
19,256 KB |
testcase_06 | AC | 128 ms
29,496 KB |
testcase_07 | AC | 123 ms
29,368 KB |
testcase_08 | AC | 155 ms
31,416 KB |
testcase_09 | AC | 164 ms
32,056 KB |
testcase_10 | AC | 172 ms
32,952 KB |
testcase_11 | AC | 103 ms
27,900 KB |
testcase_12 | AC | 172 ms
31,544 KB |
testcase_13 | AC | 122 ms
32,736 KB |
testcase_14 | AC | 158 ms
33,372 KB |
testcase_15 | AC | 101 ms
26,544 KB |
testcase_16 | AC | 101 ms
26,752 KB |
testcase_17 | AC | 129 ms
30,304 KB |
testcase_18 | AC | 135 ms
33,028 KB |
testcase_19 | AC | 89 ms
26,992 KB |
testcase_20 | AC | 85 ms
26,572 KB |
testcase_21 | AC | 115 ms
29,796 KB |
testcase_22 | AC | 125 ms
33,608 KB |
testcase_23 | AC | 112 ms
32,732 KB |
testcase_24 | AC | 113 ms
32,488 KB |
testcase_25 | AC | 138 ms
33,284 KB |
testcase_26 | AC | 144 ms
33,480 KB |
testcase_27 | AC | 113 ms
32,428 KB |
testcase_28 | AC | 141 ms
32,796 KB |
testcase_29 | AC | 144 ms
33,384 KB |
testcase_30 | AC | 176 ms
33,504 KB |
testcase_31 | AC | 157 ms
31,544 KB |
testcase_32 | AC | 105 ms
26,552 KB |
testcase_33 | AC | 120 ms
27,960 KB |
testcase_34 | AC | 119 ms
28,856 KB |
testcase_35 | AC | 153 ms
30,008 KB |
testcase_36 | AC | 138 ms
31,032 KB |
testcase_37 | AC | 141 ms
31,288 KB |
testcase_38 | AC | 150 ms
32,056 KB |
testcase_39 | AC | 159 ms
32,440 KB |
testcase_40 | AC | 186 ms
32,440 KB |
testcase_41 | AC | 224 ms
32,952 KB |
testcase_42 | AC | 209 ms
33,080 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; } #define all(x) (x).begin(),(x).end() #define fi first #define se second #define mp make_pair #define si(x) int(x.size()) const int mod=998244353,MAX=300005,INF=1<<30; vector<int> G[MAX]; vector<int> AT[MAX]; int ad[MAX],he[MAX]; int main(){ std::ifstream in("text.txt"); std::cin.rdbuf(in.rdbuf()); cin.tie(0); ios::sync_with_stdio(false); int N;cin>>N; for(int i=0;i<N-1;i++){ int a,b;cin>>a>>b;a--;b--; G[a].push_back(b); G[b].push_back(a); } int M;cin>>M; for(int i=0;i<M;i++){ int x;cin>>x;x--; for(int to:G[x]){ AT[to].push_back(x); } AT[x].push_back(x); } int ans=0; for(int i=0;i<N;i++) if(si(AT[i])) ans++; for(int i=0;i<N;i++){ if(si(AT[i])==0) continue; if(si(AT[i])==1){ ad[AT[i][0]]++; }else if(si(AT[i])==2){ int x=AT[i][0],y=AT[i][1]; if(x==i||y==i){ he[x]++; he[y]++; }else{ he[i]++; } }else{ he[i]++; } } for(int i=0;i<N;i++){ for(int to:G[i]){ he[to]+=ad[i]; } he[i]+=ad[i]; } for(int i=0;i<N;i++) cout<<ans-he[i]<<"\n"; }