# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
122781 | 2019-06-29T09:19:36 Z | davitmarg | Mousetrap (CEOI17_mousetrap) | C++17 | 69 ms | 17072 KB |
/*DavitMarg*/ #include <iostream> #include <algorithm> #include <cmath> #include <vector> #include <string> #include <cstring> #include <map> #include <unordered_map> #include <bitset> #include <set> #include <queue> #include <deque> #include <stack> #include <iterator> #include <ctype.h> #include <stdlib.h> #include <cassert> #include <fstream> #define mod 1000000007ll #define LL long long #define LD long double #define MP make_pair #define PB push_back #define all(v) v.begin(),v.end() using namespace std; int n,trap,m,used[100005],p[100005],dp[100005],ans; vector<int> g[100005],ord; void dfs(int v) { used[v]=1; if(v==trap) { p[v]=1; return; } vector<int> t; for(int i=0;i<g[v].size();i++) { int to=g[v][i]; if(used[to]) continue; dfs(to); if(!p[to]) t.PB(to); else p[v]=1; } sort(all(t),[](int a,int b) { return dp[a]>dp[b]; }); dp[v]+=t.size(); for(int i=1;i<t.size();i+=2) dp[v]+=dp[t[i]]; if(p[v]) ord.PB(v); } int main() { cin>>n>>trap>>m; for(int i=1;i<=n-1;i++) { int a,b; scanf("%d%d",&a,&b); g[a].PB(b); g[b].PB(a); } dfs(m); reverse(all(ord)); for(int i=0;i<ord.size();i++) ans+=dp[ord[i]]; cout<<ans<<endl; return 0; } /* */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2680 KB | Output is correct |
2 | Correct | 4 ms | 2808 KB | Output is correct |
3 | Correct | 4 ms | 2680 KB | Output is correct |
4 | Correct | 4 ms | 2680 KB | Output is correct |
5 | Incorrect | 4 ms | 2680 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 69 ms | 17072 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2680 KB | Output is correct |
2 | Correct | 4 ms | 2808 KB | Output is correct |
3 | Correct | 4 ms | 2680 KB | Output is correct |
4 | Correct | 4 ms | 2680 KB | Output is correct |
5 | Incorrect | 4 ms | 2680 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2680 KB | Output is correct |
2 | Correct | 4 ms | 2808 KB | Output is correct |
3 | Correct | 4 ms | 2680 KB | Output is correct |
4 | Correct | 4 ms | 2680 KB | Output is correct |
5 | Incorrect | 4 ms | 2680 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |