-
-
Save ThegeekKnight16/433cfa26bf635ae5584eed965f049d3e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
const int MAX = 2e6 + 15; | |
int n, m, e; | |
int group[MAX]; | |
vector<pair<int, int>> like, dislike; | |
int main() | |
{ | |
ios_base::sync_with_stdio(false); | |
cin.tie(NULL); | |
cin >> n >> m >> e; | |
// Condicoes de alunos que devem estar no mesmo grupo | |
while(m--){ | |
int u, v; cin >> u >> v; | |
like.emplace_back(u, v); | |
} | |
// Condicoes de alunos que devem estar em grupos diferentes | |
while(e--){ | |
int u, v; cin >> u >> v; | |
dislike.emplace_back(u, v); | |
} | |
for(int i = 1; i <= n / 3; i++){ | |
int a, b, c; cin >> a >> b >> c; | |
// Marco os alunos do i-esimo grupo | |
for(auto x : { a, b, c }) | |
group[x] = i; | |
} | |
int resp = 0; | |
// Passo pelas condicoes, atualizando a resposta | |
for(auto [u, v] : like) | |
if(group[u] != group[v]) resp++; | |
for(auto [u, v] : dislike) | |
if(group[u] == group[v]) resp++; | |
cout << resp << '\n'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment