제출 #1346650

#제출 시각아이디문제언어결과실행 시간메모리
1346650coderg300711친구 (IOI14_friend)C++20
19 / 100
11 ms1468 KiB
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pii pair<int,int>
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define pb push_back
#define sz(x) (int)(x).size()
#define rsz resize
#define ass assign
#define F(i,l,r) for(int i=(l);i<(r);++i)
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
//template<typename T> using pqg = priority_queue<T, vector<T>, greater<T>>;
#define each(a,x) for(auto a:x)
#define FOR(i,a) for(int i=0;i<(a);i++)
#define ROF(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define eb emplace_back
#define ft front()
#define V vector

#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x <<" "; _print(x); cerr << endl;
#else
#define debug(x)
#endif

void _print(ll t) {cerr << t;}
void _print(int t) {cerr << t;}
void _print(string t) {cerr << t;}
void _print(char t) {cerr << t;}
void _print(lld t) {cerr << t;}
void _print(double t) {cerr << t;}
void _print(ull t) {cerr << t;}

template <class T, class V> void _print(pair <T, V> p);
template <class T> void _print(vector <T> v);
template <class T> void _print(set <T> v);
template <class T, class V> void _print(map <T, V> v);
template <class T> void _print(multiset <T> v);
template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.ff); cerr << ","; _print(p.ss); cerr << "}";}
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}

int findSample(int n, int confidence[], int host[], int protocol[]){
  bool protocol1=1;
  F(i,1,n){
    if(protocol[i]!=1){
      protocol1=0;
      break;
    }
  }
  if(protocol1){
    int res=0;
    FOR(i,n)res+=confidence[i];
    return res;
  }
  if(n<=15){
    V<V<bool>> arefr(n,V<bool>(n,0));
    F(i,1,n){
      int h=host[i],p=protocol[i];
      if(!p)arefr[i][h]=arefr[h][i]=1;
      else if(p==1){//MyFriendsAreYourFriends
        FOR(j,i){
          if(arefr[h][j])arefr[i][j]=arefr[j][i]=1;
        }
      }else if(p==2){//WeAreYourFriends
        arefr[i][h]=arefr[h][i]=1;
        FOR(j,i){
          if(arefr[h][j])arefr[i][j]=arefr[j][i]=1;
        }
      }
    }
    int res=0;
    FOR(mask,1<<n){
      bool valid=1;
      int cur=0;
      FOR(i,n){
        if(mask&(1<<i)){
          cur+=confidence[i];
          F(j,i+1,n){
            if(mask&(1<<j)){
              if(arefr[i][j]){
                valid=0;
                break;
              }
            }
          }
        }
        if(!valid)break;
      }
      if(valid)res=max(res,cur);
    }
    return res;
  }
  return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...