# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
378289 | Dan4Life | Friend (IOI14_friend) | 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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define pb push_back
#define pf push_front
#define mp make_pair
#define fir first
#define sec second
#define all(a) a.begin(), a.end()
#define r_all(a) a.rbegin(), a.rend()
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0);
const int maxn = 1010;
const int MOD = 1e9+7; //1e9+9;
const int MOD2 = 998244353; //998244853;
const int INF = 2e9;
const ll LINF = 4e18;
int n, m, x, y, l, r, k, q;
map<int, int> M, N;
string s, ss;
set<int> S;
vector<int> adj[maxn];
int confidence[maxn], host[maxn], protocol[maxn];
int findSample(int n, int confidence[], int host[], int protocol[])
{
for(int i = 1; i < n; i++)
{
int x = host[i];
if(protocol[i]==0)
{
adj[x].pb(i),adj[i].pb(x);
}
else if(protocol[i]==1)
{
for(auto u : adj[i]){
adj[u].pb(i),adj[i].pb(u);
}
}
else
{
adj[x].pb(i),adj[i].pb(x);
for(auto u : adj[i]){
adj[u].pb(i),adj[i].pb(u);
}
}
}
int ans = 0ll;
for(int i = 0; i < n; i++)
{
S.clear();
for(int j = 0; j < n; j++) if(j!=i)S.insert(j);
for(auto u : adj[i]) S.erase(u);
for(auto u : S) ans = max(ans, confidence[i]+confidence[u]);
}
return ans;
}