Submission #369118

#TimeUsernameProblemLanguageResultExecution timeMemory
369118NachoLibreFriend (IOI14_friend)C++17
0 / 100
1047 ms65540 KiB
#include <bits/stdc++.h>
using namespace std;
#define sz(a) ((int)(a).size())
typedef vector<int> vint;
typedef vector<vint> vvint;
#ifndef wambule
#include "friend.h"
#else
#endif

int findSample(int n, int cfd[], int hst[], int ptc[]) {
	int dr = 0;
	vector<int> v[n];
	vector<pair<int, int>> u;
	for(int i = 1; i < n; ++i) {
		if(ptc[i] ^ 1) {
			v[i].push_back(hst[i]);
			v[hst[i]].push_back(i);
			u.push_back({i, hst[i]});
		}
		if(ptc[i]) {
			for(int x : v[hst[i]]) {
				v[i].push_back(x);
				v[x].push_back(i);
				u.push_back({i, x});
			}
		}
	}
	for(int b = 1; b < (1 << n); ++b) {
		bool ms = 1;
		int x = 0;
		for(int i = 0; i < u.size(); ++i) {
			if((b & (1 << u[i].first)) && (b & (1 << u[i].second))) {
				ms = 0;
				break;
			}
		}
		if(!ms) continue;
		for(int i = 0; i < n; ++i) {
			if(b & (1 << i)) {
				x += cfd[i];
			}
		}
		dr = max(dr, x);
	}
	return dr;
}

#ifdef wambule
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	return 0;
}
#endif

Compilation message (stderr)

friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:32:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |   for(int i = 0; i < u.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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...