답안 #321107

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
321107 2020-11-11T01:03:27 Z daringtrifles Traffic (IOI10_traffic) C++17
0 / 100
65 ms 94692 KB
//control+option+n to run!
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define pll pair<ll, ll>
#define FOR(i, a, b) for (signed long long i = (signed long long)(a); i < (signed long long)(b); i++)
#define NEGFOR(i, a, b) for (ll i = (a); i > (b); i--)
#define vll vector<long long>
#define sll set<long long>
#define ld long double
#define inf 1000000000000000000
#define mll multiset<long long>
#define vpll vector<pll>
#define nn << "\n"
#define ss << " "
#define F(i, b) for (ll i = 0; i < b; i++)
//10^8 operations per second
//greatest int is 2,147,483,647
//greates long long is 9.22337204e18

//ALL FUNCTIONS SHOULD BE LL!!!!

vll v[3000000];
vector <bool> visited(3000000);
vll sz(3000000);
void dfs(int node){
    
    visited[node]=1;
    ll co=0;
    for(auto i:v[node]){
        
        if (!visited[i]){
            dfs(i);
            sz[node]+=sz[i];
        }
    }

}
int LocateCentre(int n, int p[], int s[], int d[])
{
    
    FOR(i,0,n-1){
        v[s[i]].pb(d[i]);
        v[d[i]].pb(s[i]);
    }
    FOR(i,0,n){
        sz[i]+=p[i];
    }
    dfs(0);
    ll ans=inf;
    ll sum=0;
    
    FOR(i,0,n){
       sum+=p[i];            
    }
    ll accans=inf;
    FOR(i,0,n){
        if (ans>max(sz[i],sum-sz[i])) {
                       accans=i;
                       ans=max(sz[i],sum-sz[i]);
                      // cout<<max(sz[i],sum-sz[i]) nn;
                       
        }
        
    }
    return accans;
}

Compilation message

traffic.cpp: In function 'void dfs(int)':
traffic.cpp:30:8: warning: unused variable 'co' [-Wunused-variable]
   30 |     ll co=0;
      |        ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 64 ms 94692 KB Output is correct
2 Correct 63 ms 94692 KB Output is correct
3 Correct 63 ms 94692 KB Output is correct
4 Incorrect 65 ms 94692 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 64 ms 94692 KB Output is correct
2 Correct 63 ms 94692 KB Output is correct
3 Correct 63 ms 94692 KB Output is correct
4 Incorrect 65 ms 94692 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 64 ms 94692 KB Output is correct
2 Correct 63 ms 94692 KB Output is correct
3 Correct 63 ms 94692 KB Output is correct
4 Incorrect 65 ms 94692 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 64 ms 94692 KB Output is correct
2 Correct 63 ms 94692 KB Output is correct
3 Correct 63 ms 94692 KB Output is correct
4 Incorrect 65 ms 94692 KB Output isn't correct
5 Halted 0 ms 0 KB -