C - Association for Control Over Minds
You are the boss of ACM (Association for Control over Minds), an upstanding company with a single goal of world domination.
Yesterday, you woke up, and saw that the weather was clear, and the birds were singing. “Another day, another world domination plan”, you sang to yourself as you devised your next world domination plan involving the illusory mind control potions.
There’s only one insignificant problem you have to solve before you can execute this perfection of a plan: you don’t know the correct recipe for the mind control potion. You asked the local Panda-breed brewmaster for the recipe, but unfortunately he didn’t know either. Instead, he gave you the mysterious tome titled The Root of all Evil (written by Halim the White). You read the evil book under candle light, and wrote down all the potion recipes contained inside the book. “One of them must be the formula for the mind control potion, I’m sure of it!”, you said to yourself. You numbered these recipes from 1 1 1 through N N N. “I just need to try concocting all of these recipes!”, you hummed to yourself.
Today, you woke up, and saw that the weather was clear, and…, anyway. You have purchased all the utensils and ingredients from the local grocery — onion, carrot, broom, vials, cauldrons, bat wings, …, all common grocery items. Now, you are ready to begin your experiments, but then you notice that some of the recipes share common ingredients! Unfortunately, you only bought one of each ingredient with you. “Oh no! What should I do now?!”, you panicked.
“I’ll just create some of the potions today, and do the remaining ones later.”, you resolved. You consider all your recipes one by one in order by their number from recipe 1 through recipe N N N. For each recipe, if you are not able to concoct this potion (explained in the next paragraph), you skip this recipe, and consider the next one, if any. Otherwise, even though it may cause some of the next potions to no longer be concoctable, you concoct this recipe. Thus, whether to concoct a potion is not a choice. It’s simply determined by whether it is possible or not to do so when you consider the potion.
In order to concoct a potion, you first prepare a new empty cauldron (you managed to procure an infinite number of cauldrons from the grocery store). Then, you combine all of the ingredients required for this potion and nothing else in this cauldron (that is, the cauldron cannot contain any ingredients not listed in the recipe). For the ingredients that have not been used for any of the previous potions that you’ve decided to concoct, you can simply put it into this cauldron. You can also pour the entire content of the cauldron used for one of your previous concoctions into this cauldron, thus mixing in all of the ingredients contained inside the cauldron (since you pour all of the content of the cauldron, this previous concoction can no longer be used for any of your next concoctions). Finally, you stir this cauldron with your broom and take a vial of the concoction to test on your minions later. The remaining concoction remains in this cauldron, and can be poured into another cauldron later.
“What is the number of recipes you will concoct this way today?”, you asked yourself.
Input
The first line contains a non-negative integer 2 ≤ N ≤ 200000 2≤N≤200000 2≤N≤200000 giving the total number of recipes you have. Thereafter follow N N N lines, the i i i-th line describes recipe number i i i. Each of these lines is a single space separated list of integers. Each of these lines begins with an integer 1 ≤ M 1≤M 1≤M, denoting the number of ingredients required to make this recipe. Then, M M M integers follow, describing the required ingredients. The ingredients are identified by integers between 0 0 0 and 500000 500000 500000, inclusively, with different integers denoting different ingredients. For each recipe, all of its ingredients will be distinct. The sum of M M M over all recipes will be no greater than 500000 500000 500000.
Output
Print the number of recipes you will concoct.
Sample Data Explanation
In the first example, the first potion can be concocted, since both ingredients were not used so far. Thus, you will concoct this potion. The second potion will also be concocted for the same reason. The third potion cannot be concocted, since ingredient 1 1 1 is no longer present, and is inside a cauldron mixed with another ingredient not present in the recipe. The fourth potion can be concocted by pouring the content of the cauldrons used for the first and second concoctions, and then adding ingredient 5 5 5, which has remained unused so far. The last potion cannot be concocted, since the content of the cauldron for the first potion has all been poured when making the fourth potion and thus is now mixed with other ingredients not present in the recipe.
For the second example, since the first potion can be concocted, it has to be concocted. Thus, the second and third potions can no longer be concocted.
Sample #1
Input #1
5
2 1 2
2 3 4
2 1 5
5 1 2 3 4 5
2 1 2
Output #1
3
Sample #2
Input #2
3
2 1 2
1 1
1 2
Output #2
1
题目这么长 我真的想④
很神奇的一道题 等我补一下 下面是队友做出来的
#include<bits/stdc++.h>
using namespace std;
const int N = 5e5+5;
#define int long long
typedef pair<int, int>PII;
int n, m, k;
int T;
vector<int>v;
int p[N], cnt[N];
int find(int x)
{
if(p[x]!=x) p[x] = find(p[x]);
return p[x];
}
signed main()
{
ios::sync_with_stdio(false), cin.tie(0);
cin >> n;
int ans = 0;
for(int i = 0; i < 5e5+5; i ++) p[i] = i, cnt[i] = 1;
for(int i = 0; i < n; i ++)
{
v.clear();
cin >> m;
for(int i = 0; i < m; i ++)
{
int x;
cin >> x;
v.push_back(find(x));
}
sort(v.begin(), v.end());
v.erase(unique(v.begin(), v.end()), v.end());
int t = 0;
for(int i = 0; i < v.size(); i ++)
{
t += cnt[v[i]];
}
if(t == m)
{
ans ++;
for(int i = 1; i < v.size(); i ++)
{
int x = find(v[0]), y = find(v[i]);
if(x != y)
{
p[x] = y;
cnt[y] += cnt[x];
}
}
}
}
cout << ans;
return 0;
}
E - Association for Computing Machinery
签到题 对acm赛制了解就好了 每次做出来一道题都要加上当前时间t
input是做这道题需要花费的时间 总时间<=300就行
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define xx first
#define yy second
typedef pair<int, int> PII;
const int inf = 0x3f3f3f3f;
const int N = 1e6 + 10;
int v[N], n, m, k, x, t, T;
void ClearFloat()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
}
struct node
{
int a, f;
} f[N];
bool cmp(node a, node b)
{
if (a.f == b.f)
return a.a < b.a;
return a.f < b.f;
}
signed main()
{
ClearFloat();
cin >> n >> m;
for (int i = 0; i < n; i++)
{
cin >> f[i].a;
}
int tt = 0;
f[m].f = 1;
t = f[m].a;
// cout << t << endl;
tt = f[m].a;
if (f[m].a > 300)
cout << "0 0";
else
{
x = 1;
sort(f, f + n, cmp);
for (int i = 0; i < n - 1; i++)
{
tt += f[i].a;
if (f[i].a > 300 || tt > 300)
break;
t += tt;
x++;
}
cout << x << " " << t << endl;
}
return 0;
}
# [F - Air Conditioned Minions](https://vjudge.net/contest/571990#problem/F)
能搜到题的相比大家都有链接吧 我不想去vj多弄一下了 就只就用我们训练赛的链接了
!!!简单的贪心问题 和oj上面呢个题一模一样 就是判断少了个等号 谁wa这道题我笑话谁
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define xx first
#define yy second
typedef pair<int, int> PII;
const int inf = 0x3f3f3f3f;
const int N = 1e6 + 10;
int v[N], n, m, k, x, t, T;
void ClearFloat()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
}
struct node
{
int l, r;
} f[N];
bool cmp(node a, node b)
{
return a.r < b.r;
}
signed main()
{
ClearFloat();
cin >> n;
for (int i = 1; i <= n; i++)
cin >> f[i].l >> f[i].r;
sort(f + 1, f + 1 + n, cmp);
x = f[1].r, k = 1;
for (int i = 2; i <= n; i++)
if (f[i].l > x)
x = f[i].r, k++;
cout << k;
return 0;
}
G - Association for the Country of Mububa
dp真的好难 有点补不明白
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e3 + 10;
int n, a[N], dp[N];
ll sum[N], best[N];
int main()
{
cin >> n;
for (int i = 1; i <= n; ++i)
{
cin >> a[i];
sum[i] = sum[i - 1] + a[i];
}
for (int i = 1; i <= n; ++i)
{
for (int j = i - 1; j >= 0; --j)
{
if (sum[i] - sum[j] >= best[j])
{
best[i] = sum[i] - sum[j];
dp[i] = dp[j] + 1;
// cout << i << " " << j << " " << best[i] << " " << dp[i] << endl;
break;
}
}
}
cout << dp[n];
return 0;
}
一定补题
∗
∗
下次一定
∗
∗
**下次一定**
∗∗下次一定∗∗