当前位置:网站首页>CF1634E Fair Share
CF1634E Fair Share
2022-07-05 05:31:00 【solemntee】

The question : Yes m m m An array , The number of numbers in each array is even . Divide each array in half to the set A 、 B A、B A、B Make the final resettable same, judge whether it is legal, and give the scheme .
First of all, I probably only think of Euler circuit on the court , But because there is no demolition point to build a map , We can only do the case of non re set , Later, I had no choice but to broadcast .
The method is to create a bipartite map , Left m m m Dots represent each array , Right c n t cnt cnt( Number of digital categories ) A little bit .
Numbers from the left to the right i i i The directed edge of represents i i i among A A A aggregate , On the contrary, it means to give B B B aggregate . It is easy to know that the original problem is equivalent to searching Euler circuits on bipartite graphs .
Then because there is no need to output the path , Just dye the edges with black and white , Then keep searching the ring .
Then finding a ring will not affect the Euler circuit property of the complementary graph , It is also obvious that Euler can definitely search a ring , That's it .
By the way, please enjoy the new one l a m b d a lambda lambda function
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
int m;
scanf("%d",&m);
vector<vector<int>>a(m+1),ans(m+1);
map<int,int>mp,cnt;
int asdf=0;
for(int i=1;i<=m;i++)
{
int n;
scanf("%d",&n);
a[i].resize(n+1);
ans[i].resize(n+1,-1);
for(int j=1;j<=n;j++)
{
scanf("%d",&a[i][j]);
if(mp[a[i][j]]==0)mp[a[i][j]]=++asdf;
cnt[mp[a[i][j]]]++;
}
}
for(int i=1;i<=asdf;i++)if(cnt[i]%2==1)
{
printf("NO");
return 0;
}
vector<vector<pair<int,int>>>gra(4e5+5);
vector<int>cur(4e5+5);
const int MX=2e5;
for(int i=1;i<=m;i++)
{
for(int j=1;j<a[i].size();j++)
{
gra[i].push_back({
mp[a[i][j]]+MX,j});
gra[MX+mp[a[i][j]]].push_back({
i,j});
cur[i]++;
cur[MX+mp[a[i][j]]]++;
}
}
function<void(int,int)>dfs=[&](int now,int flag)
{
int u=now;
while(cur[u])
{
cur[u]--;
auto [to,pos]=gra[u][cur[u]];
while(ans[min(u,to)][pos]<0)
{
ans[min(u,to)][pos]=flag;
dfs(to,1-flag);
}
}
};
for(int i=1;i<=m;i++)dfs(i,0);
printf("YES\n");
for(int i=1;i<=m;i++)
{
for(int j=1;j<ans[i].size();j++)
{
if(ans[i][j]==0)printf("L");
else printf("R");
}
printf("\n");
}
return 0;
}
边栏推荐
- 【Jailhouse 文章】Jailhouse Hypervisor
- [to be continued] I believe that everyone has the right to choose their own way of life - written in front of the art column
- 利用HashMap实现简单缓存
- 发现一个很好的 Solon 框架试手的教学视频(Solon,轻量级应用开发框架)
- Yolov5 ajouter un mécanisme d'attention
- 剑指 Offer 05. 替换空格
- 读者写者模型
- Acwing 4300. Two operations
- [turn to] MySQL operation practice (I): Keywords & functions
- Demonstration of using Solon auth authentication framework (simpler authentication framework)
猜你喜欢

The present is a gift from heaven -- a film review of the journey of the soul

剑指 Offer 04. 二维数组中的查找

Sword finger offer 53 - I. find the number I in the sorted array
![[depth first search] 695 Maximum area of the island](/img/08/cfff4aec667216e4f146205a12c13f.jpg)
[depth first search] 695 Maximum area of the island

Improvement of pointnet++

Codeforces round 712 (Div. 2) d. 3-coloring (construction)

Talking about JVM (frequent interview)

lxml.etree.XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8
![To be continued] [UE4 notes] L4 object editing](/img/0f/cfe788f07423222f9eed90f4cece7d.jpg)
To be continued] [UE4 notes] L4 object editing

C language Essay 1
随机推荐
读者写者模型
过拟合与正则化
软件测试 -- 0 序
Chapter 6 data flow modeling - after class exercises
Find a good teaching video for Solon framework test (Solon, lightweight application development framework)
【实战技能】非技术背景经理的技术管理
Acwing 4301. Truncated sequence
Educational Codeforces Round 107 (Rated for Div. 2) E. Colorings and Dominoes
Introduction to memory layout of FVP and Juno platforms
[merge array] 88 merge two ordered arrays
[binary search] 69 Square root of X
卷积神经网络——卷积层
PMP candidates, please check the precautions for PMP examination in July
[allocation problem] 455 Distribute cookies
Configuration and startup of kubedm series-02-kubelet
利用HashMap实现简单缓存
Drawing dynamic 3D circle with pure C language
剑指 Offer 05. 替换空格
Using HashMap to realize simple cache
[turn]: Apache Felix framework configuration properties