MSBOP 2015 Round3 register

Ended

Participants:978

Verdict:AC | AC
Submitted:2015-05-09 14:22:43

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;
vector<int> g[101000];
int use[101000],a[101000];
int n,s;
void dfs(int x){
    //printf("!!!%d\n", x);
    use[x]=1;
    for (int i=0; i<g[x].size(); ++i)
        if (! use[g[x][i]]){
            dfs(g[x][i]); a[x]+=a[g[x][i]];
        }
}
int main(){
    int test=0;
    scanf("%d", &test);
    for (int T=1; T<=test; ++T){
        printf("Case #%d: ", T);
        scanf("%d %d", &n,&s); --s;
        for (int i=0; i<n; ++i){
            g[i].clear(); use[i]=0;
        }
        for (int i=0; i<n-1; ++i){
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX