#include <bits/stdc++.h>
#define int long long
using namespace std;
struct lst_t
{
int t, x, y;
} lst[255];
int n, t, cnt, mx, mn = LLONG_MAX;
string s;
bool cmp(lst_t x, lst_t y)
{
return x.t < y.t;
}
signed main()
{
cin >> n >> t >> s;
for(int i = 1; i <= t; i++)
{
cin >> lst[i].t >> lst[i].x >> lst[i].y;
}
sort(lst + 1, lst + 1 + t, cmp);
for(int z = 1; z <= n; z++)
{
bool f = 0;
for(int k = 0; k <= t + 1; k++)
{
bool f2 = 1;
int cs[n + 5] = {};
memset(cs, -1, sizeof(cs));
cs[z] = k;
for(int i = 1; i <= t; i++)
{
if(cs[lst[i].x] == -1 && cs[lst[i].y] > 0)
{
cs[lst[i].y]--;
cs[lst[i].x] = k;
}
else if(cs[lst[i].y] == -1 && cs[lst[i].x] > 0)
{
cs[lst[i].x]--;
cs[lst[i].y] = k;
}
else if(cs[lst[i].x] >= 0 && cs[lst[i].y] >= 0)
{
cs[lst[i].x] = max(0ll, cs[lst[i].x] - 1);
cs[lst[i].y] = max(0ll, cs[lst[i].y] - 1);
}
}
for(int i = 1; i <= n; i++)
{
if((s[i - 1] == '1' && cs[i] == -1) || (s[i - 1] == '0' && cs[i] != -1))
{
f2 = 0;
}
}
if(f2)
{
mx = max(mx, k);
mn = min(mn, k);
f = 1;
}
}
cnt += f;
}
cout << cnt << " " << mn;
if(mx == t + 1)
{
cout << " Infinity";
}
else
{
cout << " " << mx;
}
return 0;
}
15008:跟踪
最新推荐文章于 2024-09-17 10:36:22 发布