# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
347943 | isym444 | Traffic (IOI10_traffic) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "traffic.h"
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <iostream>
using namespace std;
/* using std::vector; */
#define fo(i, n) for (i = 0; i < n; i++)
#define ll long long
#define sz(x) (int)(x).size()
#define mp make_pair
typedef pair<ll, ll> pl;
#define pb push_back
/* void setIO(string name = "")
{ // name is nonempty for USACO file I/O
ios_base::sync_with_stdio(0);
cin.tie(0); // see Fast Input & Output
// alternatively, cin.tie(0)->sync_with_stdio(0);
if (sz(name))
{
freopen((name + ".in").c_str(), "r", stdin); // see Input & Output
freopen((name + ".out").c_str(), "w", stdout);
}
} */
// -----------------------------
const int MX = 1000;
const int INF = 2e9 + 1;
int fans = 0;
vector<int> g[MX], nodes(MX), people(MX), children(MX);
int p[MX];
void dfs (int v, int parent) {
}
int LocateCentre (int n) {
//h cycle through tree p, selecting each node to be root
//h for each tree, do dfs, finding minimum max value of sums of subtrees
int curmax;
int totalmin=INF;
int ans;
for(int i = 0; i<n; i++)
{
int ls=0;
int rs=0;
for(int k = 0; k<i; k++)
{
ls+=p[k];
}
for(int t = i+1; t<=n-1; t++)
{
rs+=p[t];
}
curmax=max(ls,rs);
if(curmax<totalmin)
{
totalmin=curmax;
ans=i;
}
}
//cout << ans;
return ans;
}
/* int main ()
{
ios_base::sync_with_stdio(0);
setIO("cpp");
int n;
cin >> n;
for(int i = 0; i<n; i++)
{
cin >> p[i];
}
LocateCentre(n);
} */
//h populations of cities 0-3: 1 1 1 1000
//h cities joined by roads as follows: 0->1->2->3