Submission #431563

#TimeUsernameProblemLanguageResultExecution timeMemory
431563SAADTraffic (IOI10_traffic)C++17
0 / 100
16 ms24780 KiB
#define F first #define S second #define rep(i,a,b) for(int i=a;!(a==b&&i!=b)&&((i<=b&&b>=a)||(i>=b&&a>=b));i+=(a<=b?1:-1)) #define pb push_back #define Fbitl __builtin_ffs #define bit1 __builtin_popcount //#include <bits/stdc++.h> #include <iostream> #include <math.h> #include <algorithm> #include <string.h> #include <vector> #include <queue> #include <map> #include <unordered_map> //#include "memory.h" using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<string, string> pss; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<pii> vii; typedef vector<ll> vl; typedef vector<vl> vvl; vector <int> x[(int)1e6 + 2]; bool visa[(int)1e6 + 2]; ll ans[(int)1e6 + 2], p[(int)1e6 + 1]; ll all; int SAAD(int idx , int from) { visa[idx] = false; ll sum = 0,a; for (int i = 0; i < x[idx].size(); i++) { if (visa[x[idx][i]]) { a = SAAD(x[idx][i],idx); sum += a; ans[idx] = max(ans[idx],a); } } sum += p[idx]; if (from == -1) return sum; ans[idx] = max(ans[idx],all-sum); return sum ; } int LocateCentre(int N, int P[], int S[], int D[]) { memset(visa, 1, sizeof(visa)); for (int i = 0; i < N-1; i++) { x[S[i]].pb(D[i]); x[D[i]].pb(S[i]); } for (int i = 0; i < N; i++) { all += P[i]; p[i] = P[i]; } SAAD(0,-1); ll mn = 2e9; for ( int i = 0; i < N; i++) { mn = min(mn,ans[i]); } return mn; }

Compilation message (stderr)

traffic.cpp: In function 'int SAAD(int, int)':
traffic.cpp:34:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     for (int i = 0; i < x[idx].size(); i++)
      |                     ~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...