diff --git a/.gitignore b/.gitignore index 5a5a125..664ec77 100755 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ build *.json /cmake-build* /build* -/test*.txt \ No newline at end of file +/test*.txt +/out \ No newline at end of file diff --git a/src/P1395/P1395.cpp b/src/P1395/P1395.cpp new file mode 100644 index 0000000..eb8caa1 --- /dev/null +++ b/src/P1395/P1395.cpp @@ -0,0 +1,40 @@ +#include +#include +#include + +using ll = int64_t; +using vl = std::vector; +auto &ci = std::cin; +auto &co = std::cout; + +const ll max_n = 5e4+5; +ll *sn = new ll[max_n]; +auto *nds = new vl[max_n]; + +void dfs(ll ft, ll n){ + if(nds[n].size()<=1){ + return; + } + sn[n]=1; + for(ll i:nds[n]){ + if(i==ft){ + continue; + } + dfs(n, i); + sn[n]+=sn[i]; + } + return; +} + +int main(){ + ll n; + ci>>n; + for(ll i{1}; i>a>>b; + nds[a].push_back(b); + nds[b].push_back(a); + } + for(ll i{1};i<=n;i++)co<