Pagini recente »
Istoria paginii runda/2023-12-20-clasa-7-tema-14-optional
|
Rating Alexandru Zoescu (alexstiemaibine12345)
|
Istoria paginii runda/2020-12-04-clasa-6-tema-14/clasament
|
Rating predescu (bebeetare)
|
Cod sursă (job #570850)
Cod sursă (job
#570850)
#include <bits/stdc++.h>
using namespace std;
ifstream in ("canibali.in");
ofstream out ("canibali.out");
struct S {
int x, y, z, t;
} v[2050];
int n;
vector <int> g[4100];
bool viz[4100];
int l[4100], r[4100];
bool match(int nod) {
viz[nod] = 1;
for(auto &fiu : g[nod]) {
if(!r[fiu] || (!viz[r[fiu]] && match(r[fiu]))) {
l[nod] = fiu;
r[fiu] = nod;
return 1;
}
}
return 0;
}
void matching() {
bool ok = 1;
while(ok) {
ok = 0;
for(int i = 1; i <= 2 * n; i++)
viz[i] = 0;
for(int i = 1; i <= 2 * n; i++) {
if(!viz[i] && !l[i])
ok |= match(i);
}
}
}
int main() {
in >> n;
for(int i = 1; i <= n; i++)
in >> v[i].x >> v[i].y >> v[i].z >> v[i].t;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= n; j++) {
if(v[i].x == v[j].x && v[i].y == v[j].y && v[i].z == v[j].z && v[i].t == v[j].t && j <= i)
continue;
if(v[i].x >= v[j].x && v[i].y >= v[j].y && v[i].z >= v[j].z && v[i].t >= v[j].t) {
g[i].push_back(j);
g[n + i].push_back(j);
}
}
}
matching();
int ans = 0;
for(int i = 1; i <= n; i++) {
if(!r[i])
ans++;
}
out << ans;
return 0;
}