Solution Set -「ARC 124」
「ARC 124A」LR Constraints
Link.
我们可以把 \(1\sim n\) 个盒子里能放的球的编号集合全部求出来。然后就直接来。
注意题目已经给出了 \(k\) 个球的位置,所以「Note that for each integer \(i\) from \(1\) through \(K\), there must be at least one card on which we write \(i\).」这个限制不用管。
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define len(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
const int N=1100,MOD=998244353;
int n,k,ts[N],tek[N],fin[N],Rs[N];
set<int> rs[N];
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr),cout.tie(nullptr);
cin>>n>>k,memset(fin,-1,sizeof fin);
for(int i=1; i<=k; ++i) {
char c; cin>>c;
ts[i]=(c=='R');
cin>>tek[i];
Rs[tek[i]]=ts[i];
}
for(int i=1; i<=k; ++i) {
if(~fin[tek[i]]) return puts("0"),0;
fin[tek[i]]=i;
}
for(int i=1; i<=n; ++i) {
if(~fin[i]) rs[i].emplace(fin[tek[i]]);
else {
auto &s=rs[i];
for(int j=1; j<=k; ++j) s.emplace(j);
int tmp=0;
for(int j=i+1; j<=n; ++j) {
if(!Rs[j]) s.erase(fin[j]);
}
for(int j=1; j<i; ++j) {
if(Rs[j]) s.erase(fin[j]);
}
}
}
int res=1;
for(int i=1; i<=n; ++i) res*=len(rs[i]),res%=MOD;
cout<<res<<"\n";
return 0;
}
「ARC 124B」XOR Matching 2
Link.
预处理出 \(s(i,j)=a_{i}\oplus b_{j}\),以及 \(pos(i,x)\) 表示第 \(i\) 层值 \(x\) 的出现集合,用 std::map 均摊 \(\mathcal{O}(n^{2})\) 空间。然后我们在第一层逐列考虑,对于第一层的每一种异或值,找出在每一行出现的位置集合,如果某一行没有出现就不行。最后就看集合大小是否等于 \(n\)。
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define int ll
const int N=2100;
int a[N],b[N],xr[N][N],n;
multimap<int,int> mp[N];
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr),cout.tie(nullptr);
cin>>n;
for(int i=1; i<=n; ++i) cin>>a[i];
for(int i=1; i<=n; ++i) cin>>b[i];
for(int i=1; i<=n; ++i) for(int j=1; j<=n; ++j) xr[i][j]=(a[i] xor b[j]),mp[i].insert({xr[i][j],j});
vector<int> res;
for(int j=1; j<=n; ++j) {
bool ok=0;
set<int> S;
for(int i=1; i<=n; ++i) {
auto rg=mp[i].equal_range(xr[1][j]);
if(mp[i].find(xr[1][j])!=mp[i].end()) {
for(auto it=rg.first; it!=rg.second; ++it) {
S.emplace(it->second);
}
}
else {
ok=1;
break;
}
}
if(ok) continue;
if(S.size()==n) {
res.push_back(xr[1][j]);
}
}
sort(all(res));
res.erase(unique(all(res)),res.end());
cout<<res.size()<<"\n";
for(int x:res) cout<<x<<"\n";
return 0;
}
「ARC 124C」LCM of GCDs
Link.
考场做法复杂度有问题啊,虽然屮过去了。有空来补 official editorial 做法。
// Oops, something went wrong.
「ARC 124D」Yet Another Sorting Problem
Link.
你看 ARC 又考置换群了。震撼围观吴老师精确押题。
套路题,连边 \(i\rightarrow p_{i}\) 后一堆环摆出来。答案是
2\times\max\{\text{the number of cycles of size of 2 or greater consisting of vertice numbered through }1\text{ to }n,\\
\text{the number of cycles of size of 2 or greater consisting of vertice numbered through }n+1\text{ to }n+m\}
\]
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int N=200100;
int n,m,p[N],vis[N];
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr),cout.tie(nullptr);
cin>>n>>m; int x0=0,x1=0,res=n+m,ls=0;
for(int i=1; i<=n+m; ++i) cin>>p[i];
for(int i=1; i<=n+m; ++i) {
if(vis[i]) continue;
int now=i,len=0,qwq=0,qaq=0;
while(!vis[now]) {
++len;
if(now<=n) qwq=1;
else qaq=1;
vis[now]=1;
now=p[now];
}
if(!qaq&&len>=2) ++x0;
if(!qwq&&len>=2) ++x1;
--res;
}
cout<<res+2*max(x0,x1)<<"\n";
return 0;
}
「ARC 124E」Pass to Next
Link.
「ARC 124F」Chance Meeting
Link.
Solution Set -「ARC 124」的更多相关文章
- Solution Set -「ARC 107」
「ARC 107A」Simple Math Link. 答案为: \[\frac{a(a+1)\cdot b(b+1)\cdot c(c+1)}{8} \] 「ARC 107B」Quadrup ...
- 「ARC 139F」Many Xor Optimization Problems【线性做法,踩标】
「ARC 139F」Many Xor Optimization Problems 对于一个长为 \(n\) 的序列 \(a\),我们记 \(f(a)\) 表示从 \(a\) 中选取若干数,可以得到的最 ...
- Solution -「ARC 104E」Random LIS
\(\mathcal{Description}\) Link. 给定整数序列 \(\{a_n\}\),对于整数序列 \(\{b_n\}\),\(b_i\) 在 \([1,a_i]\) 中等概率 ...
- Diary / Solution Set -「WC 2022」线上冬眠做噩梦
大概只有比较有意思又不过分超出能力范围的题叭. 可是兔子的"能力范围" \(=\varnothing\) qwq. 「CF 1267G」Game Relics 任意一个 ...
- Solution -「ARC 101D」「AT4353」Robots and Exits
\(\mathcal{Description}\) Link. 有 \(n\) 个小球,坐标为 \(x_{1..n}\):还有 \(m\) 个洞,坐标为 \(y_{1..m}\),保证上述坐标 ...
- Solution -「ARC 110D」Binomial Coefficient is Fun
\(\mathcal{Description}\) Link. 给定非负整数序列 \(\{a_n\}\),设 \(\{b_n\}\) 是一个非负整数序列且 \(\sum_{i=1}^nb_i\ ...
- Solution -「ARC 124E」Pass to Next
\(\mathcal{Description}\) Link. 有 \(n\) 个人站成一个环,初始时第 \(i\) 个人手里有 \(a_i\) 个球.第 \(i\) 个人可以将自己手中任意数 ...
- Solution -「ARC 126E」Infinite Operations
\(\mathcal{Description}\) Link. 给定序列 \(\{a_n\}\),定义一次操作为: 选择 \(a_i<a_j\),以及一个 \(x\in\mathbb R ...
- Solution -「ARC 126F」Affine Sort
\(\mathcal{Description}\) Link. 给定 \(\{x_n\}\),令 \[f(k)=\left|\{(a,b,c)\mid a,b\in[0,c),c\in[1,k ...
- Solution -「ARC 125F」Tree Degree Subset Sum
\(\mathcal{Description}\) Link. 给定含有 \(n\) 个结点的树,求非负整数对 \((x,y)\) 的数量,满足存在 \(\exist S\subseteq V ...
随机推荐
- Galaxy Release 20.05 发布,新增多项可视化体验
Galaxy Project(https://galaxyproject.org/)是在云计算背景下诞生的一个生物信息学可视化分析开源项目. 该项目由美国国家科学基金会(NSF).美国国家人类基因组研 ...
- ggplot2 调整绘图区域大小
熟悉 R 绘图的朋友肯定知道,在普通绘图中,图片的大小可以直接在 png() 和 pdf() 中指定,而绘图区大小则可以用 par() 中的 mar 或 mai 来指定.但是在 ggplot2 中,图 ...
- CSS3实现3D效果的图片墙
先来看一下效果:http://39.105.101.122/myhtml/CSS/transform_3D/img_3D.html 目前没有做IE的兼容,在谷歌浏览器里面可以看到效果 布局结构: &l ...
- 使用 InstructPix2Pix 对 Stable Diffusion 进行指令微调
本文主要探讨如何使用指令微调的方法教会 Stable Diffusion 按照指令 PS 图像.这样,我们 Stable Diffusion 就能听得懂人话,并根据要求对输入图像进行相应操作,如: 将 ...
- 一篇讲懂Java运行类型、编译类型和多态(面向对象语言精髓之一)
对象:运行类型.编译类型和多态 1.搞清楚面向对象的运行类型和编译类型就掌握了对象的精髓,我们用举个例子 class Father { Father() { System.out.println(&q ...
- k8s驱逐篇(6)-kube-controller-manager驱逐-NodeLifecycleController源码分析
概述 k8s v1.16版本中NodeController已经分为了NodeIpamController与NodeLifecycleController,本文主要介绍NodeLifecycleCont ...
- Bean生命周期的扩展点:Bean Post Processor
摘要:在本篇文章中,我们将深入探讨Spring框架中的重要组件--BeanPostProcessor.首先,我们将了解其设计理念和目标,然后通过实际的例子学习如何基础使用它,如何通过BeanPostP ...
- .NET Core 允许跨域的两种方式实现(IIS 配置、C# 代码实现)
〇.前言 当把开发好的 WebApi 接口,部署到 Windows 服务器 IIS 后,postman 可以直接访问到接口并正确返回,这并不意味着任务完成,毕竟接口嘛是要有交互的,最常见的问题莫过于跨 ...
- ASL单芯片CS5366TypeC转HDMI4K60HZ加HUB多口方案|CS5366带PD拓展方案原理图
CS5366芯片是ASL集睿致远最新推出的2Len带PD的扩展坞方案芯片,CS5366支持4K60HZ. 在分辨率4K下,刷新率60HZ对于30HZ看似提升不多,但是对于应用在游戏主座的客户来说至关重 ...
- MySQL中如何定位阻塞语句
数据库中阻塞语句的查询和分析 前言 MySQL 1.使用 show processlist 查询正在运行的进程 2.使用 INNODB_TRX 查询当前运行的事务 3.使用 INNODB_LOCKS ...