Submission #893419

# Submission time Handle Problem Language Result Execution time Memory
893419 2023-12-27T04:39:01 Z vjudge1 Meetings 2 (JOI21_meetings2) C++17
4 / 100
23 ms 604 KB
#include <bits/stdc++.h>
#define int long long
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define pb push_back
using namespace std;
const int N=1005;
vector <int> g[N];
int d[N][N];
int ans[N];
signed main(){
    int n;
    cin>>n;
    for(int i=0;i<n-1;i++){
        int u,v;
        cin>>u>>v;
        g[u].pb(v);
        g[v].pb(u);
    }
    queue <int> q;
    for(int i=1;i<=n;i++){
        q.push(i);
        d[i][i]=0;
        while(!q.empty()){
            int v=q.front();
            q.pop();
            for(auto to : g[v]){
                if(d[i][to]==0 && to!=i){
                    d[i][to]=d[i][v]+1;
                    q.push(to);
                }
            }
        }
    }
    
    for(int i=0;i<(1<<n);i++){
        vector <int> v;
        for(int j=0;j<n;j++){
            if((i & (1<<j))!=0){
                v.pb(j);
            }
        }
        int mn=1e9,cnt=0;
        for(int i=1;i<=n;i++){
            int sum=0;
            for(auto x : v){
                sum+=d[i][x+1];
            }
            if(sum<mn){
                mn=sum;
                cnt=1;
            }
            else if(sum==mn)cnt++;
        }
        ans[v.size()]=max(ans[v.size()],cnt);
    }
    for(int i=1;i<=n;i++){
        cout<<ans[i]<<"\n";
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 4 ms 344 KB Output is correct
5 Correct 4 ms 348 KB Output is correct
6 Correct 4 ms 348 KB Output is correct
7 Correct 4 ms 348 KB Output is correct
8 Correct 8 ms 524 KB Output is correct
9 Correct 16 ms 532 KB Output is correct
10 Correct 16 ms 348 KB Output is correct
11 Correct 21 ms 528 KB Output is correct
12 Correct 19 ms 596 KB Output is correct
13 Correct 16 ms 348 KB Output is correct
14 Correct 4 ms 348 KB Output is correct
15 Correct 4 ms 348 KB Output is correct
16 Correct 8 ms 348 KB Output is correct
17 Correct 20 ms 348 KB Output is correct
18 Correct 23 ms 348 KB Output is correct
19 Correct 8 ms 344 KB Output is correct
20 Correct 16 ms 348 KB Output is correct
21 Correct 8 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 4 ms 344 KB Output is correct
5 Correct 4 ms 348 KB Output is correct
6 Correct 4 ms 348 KB Output is correct
7 Correct 4 ms 348 KB Output is correct
8 Correct 8 ms 524 KB Output is correct
9 Correct 16 ms 532 KB Output is correct
10 Correct 16 ms 348 KB Output is correct
11 Correct 21 ms 528 KB Output is correct
12 Correct 19 ms 596 KB Output is correct
13 Correct 16 ms 348 KB Output is correct
14 Correct 4 ms 348 KB Output is correct
15 Correct 4 ms 348 KB Output is correct
16 Correct 8 ms 348 KB Output is correct
17 Correct 20 ms 348 KB Output is correct
18 Correct 23 ms 348 KB Output is correct
19 Correct 8 ms 344 KB Output is correct
20 Correct 16 ms 348 KB Output is correct
21 Correct 8 ms 348 KB Output is correct
22 Runtime error 1 ms 604 KB Execution killed with signal 11
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 4 ms 344 KB Output is correct
5 Correct 4 ms 348 KB Output is correct
6 Correct 4 ms 348 KB Output is correct
7 Correct 4 ms 348 KB Output is correct
8 Correct 8 ms 524 KB Output is correct
9 Correct 16 ms 532 KB Output is correct
10 Correct 16 ms 348 KB Output is correct
11 Correct 21 ms 528 KB Output is correct
12 Correct 19 ms 596 KB Output is correct
13 Correct 16 ms 348 KB Output is correct
14 Correct 4 ms 348 KB Output is correct
15 Correct 4 ms 348 KB Output is correct
16 Correct 8 ms 348 KB Output is correct
17 Correct 20 ms 348 KB Output is correct
18 Correct 23 ms 348 KB Output is correct
19 Correct 8 ms 344 KB Output is correct
20 Correct 16 ms 348 KB Output is correct
21 Correct 8 ms 348 KB Output is correct
22 Runtime error 1 ms 604 KB Execution killed with signal 11
23 Halted 0 ms 0 KB -