(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #333899

#TimeUsernameProblemLanguageResultExecution timeMemory
333899AldewTraffic (IOI10_traffic)C++14
100 / 100
1175 ms159040 KiB
/* ID: alec3 LANG: C++14 PROG: /* Credit to Oscar Garries */ #include <bits/stdc++.h> #define check(x) cout<<(#x)<<": "<<x<<" " << endl; #define line cout << "--------------" << endl; #define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define ss second #define ff first #define pb push_back #define lb lower_bound #define ub upper_bound #define ld long double #define all(c) (c).begin(), (c).end() #define FOR(i, a, b) for (int i = a; i < b; i++) #define F0R(i, n) for (int i = 0; i < n; i++) typedef long long ll; typedef unsigned long long ull; int pct(int x) { return __builtin_popcount(x); } using namespace std; void setIO(string name) { freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout); ios_base::sync_with_stdio(0); } int fans = 0; vector<int> adj[(int)1e6], nodes(1e6), people(1e6), children(1e6); void dfs(int v, int parent){ for (auto x : adj[v]){ if (x == parent) continue; dfs(x, v); children[v] += children[x]; people[v] = max(people[v], children[x]); } people[v] = max(people[v], fans-children[v] - nodes[v]); children[v] += nodes[v]; return; } int LocateCentre (int n, int p[], int d[], int s[]){ F0R(i, n){ fans += p[i]; nodes[i] = p[i]; } F0R(i, n-1){ adj[s[i]].pb(d[i]); adj[d[i]].pb(s[i]); } dfs(0, -1); int sol = INT_MAX, ans = -1; F0R(i, n){ if (people[i] < sol){ ans = i; sol = people[i]; } } return ans; }

Compilation message (stderr)

traffic.cpp:5:1: warning: "/*" within comment [-Wcomment]
    5 | /*
      |  
traffic.cpp: In function 'void setIO(std::string)':
traffic.cpp:35:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   35 |  freopen((name+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
traffic.cpp:36:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   36 |  freopen((name+".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...