| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 577740 | juggernaut | Star Trek (CEOI20_startrek) | C++14 | 3 ms | 2644 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define fr first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
#define USING_ORDERED_SET 0
#if USING_ORDERED_SET
#include<bits/extc++.h>
using namespace __gnu_pbds;
template<class T>using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
#endif
template<class T>void umax(T &a,T b){if(a<b)a=b;}
template<class T>void umin(T &a,T b){if(b<a)a=b;}
#ifdef juggernaut
    #define printl(args...) printf(args)
#else
    #define printl(args...) 0
#endif
int n;
ll d;
vector<int>g[100005];
ll dp[100005];
void dfs(int v,int p){
	ll carry=0;
	for(int to:g[v])if(to^p){
		dfs(to,v);
		if(dp[to]<0)dp[v]-=dp[to];
		else carry-=dp[to];
	}
	if(!dp[v])dp[v]=carry;
	if(!dp[v])dp[v]--;
}
ll mod=1e9+7;
ll ans;
ll losers;
void go(int v,int p,bool depth){
	if(depth){
		if(dp[v]>0)ans+=n;
		else ans+=losers;
	}else{
		if(dp[v]<0)ans+=(n-losers);
	}
	for(int to:g[v])if(to^p)go(to,v,depth^1);
}
int main(){
	scanf("%d%lld",&n,&d);
	for(int i=1;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		g[x].push_back(y);
		g[y].push_back(x);
	}
	dfs(1,0);
	for(int i=1;i<=n;i++)if(dp[i]<0)losers++;
	go(1,0,1);
	ans%=mod;
	printf("%lld",ans);
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
