「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}\) 后一堆环摆出来。答案是

\[n+m-(\text{the number of cycles in the graph})+\\
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」的更多相关文章

  1. 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 ...

  2. 「ARC 139F」Many Xor Optimization Problems【线性做法,踩标】

    「ARC 139F」Many Xor Optimization Problems 对于一个长为 \(n\) 的序列 \(a\),我们记 \(f(a)\) 表示从 \(a\) 中选取若干数,可以得到的最 ...

  3. Solution -「ARC 104E」Random LIS

    \(\mathcal{Description}\)   Link.   给定整数序列 \(\{a_n\}\),对于整数序列 \(\{b_n\}\),\(b_i\) 在 \([1,a_i]\) 中等概率 ...

  4. Diary / Solution Set -「WC 2022」线上冬眠做噩梦

      大概只有比较有意思又不过分超出能力范围的题叭.   可是兔子的"能力范围" \(=\varnothing\) qwq. 「CF 1267G」Game Relics   任意一个 ...

  5. Solution -「ARC 101D」「AT4353」Robots and Exits

    \(\mathcal{Description}\)   Link.   有 \(n\) 个小球,坐标为 \(x_{1..n}\):还有 \(m\) 个洞,坐标为 \(y_{1..m}\),保证上述坐标 ...

  6. Solution -「ARC 110D」Binomial Coefficient is Fun

    \(\mathcal{Description}\)   Link.   给定非负整数序列 \(\{a_n\}\),设 \(\{b_n\}\) 是一个非负整数序列且 \(\sum_{i=1}^nb_i\ ...

  7. Solution -「ARC 124E」Pass to Next

    \(\mathcal{Description}\)   Link.   有 \(n\) 个人站成一个环,初始时第 \(i\) 个人手里有 \(a_i\) 个球.第 \(i\) 个人可以将自己手中任意数 ...

  8. Solution -「ARC 126E」Infinite Operations

    \(\mathcal{Description}\)   Link.   给定序列 \(\{a_n\}\),定义一次操作为: 选择 \(a_i<a_j\),以及一个 \(x\in\mathbb R ...

  9. 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 ...

  10. Solution -「ARC 125F」Tree Degree Subset Sum

    \(\mathcal{Description}\)   Link.   给定含有 \(n\) 个结点的树,求非负整数对 \((x,y)\) 的数量,满足存在 \(\exist S\subseteq V ...

随机推荐

  1. Java(类与对象、封装)

    面向过程.面向对象 面向对象编程(Object-Oriented Programming, OOP) 本质:以类的方式组织代码,以对象的组织(封装)数据. 抽象 三大特性 封装 继承 多态 从认识论的 ...

  2. 用R来分析洛杉矶犯罪

    由于微信不允许外部链接,你需要点击文章尾部左下角的 "阅读原文",才能访问文中链接. 洛杉矶市(Los Angeles)或"爵士乐的诞生地(The Birthplace ...

  3. 5 大数据实战-hive实战分析

    1 内部表 Show databses; Use hive_data; 1.1 创建内部表 CREATE TABLE SOGOUQ2(DT STRING,WEBSESSION STRING,WORD ...

  4. 【promptulate专栏】ChatGPT框架——两行代码构建一个强大的论文总结助手

    本文节选自笔者博客:https://www.blog.zeeland.cn/archives/019hasaa 前言 如果你经常阅读论文,那么你肯定会遇到以下几个问题: 论文晦涩难懂看不明白怎么办? ...

  5. TypeScript又出新关键字了?

    TypeScript 5.2将引入一个新的关键字:using.当它离开作用域时,你可以用Symbol.dispose函数来处置任何东西. { const getResource = () => ...

  6. 快上车,搭乘HUAWEI HiCar驶向未来

    HUAWEI HiCar(以下简称HiCar)是华为提供的人-车-家全场景智慧互联解决方案,连接手机与车辆,充分发挥各自的优势属性,将手机的应用/服务生态延伸进车辆,实现以手机为核心的全场景体验.消费 ...

  7. 基于C# 开发的SOL SERVER 操作数据库类(SQLHelp)

    说明:以下是我近两年年来开发中最常用的C#操作sql server数据库访问类,对初学者非常有用,容易扩展,支持多库操作,多研究研究,有什么问题欢迎留言 当前环境为 C#  .NET CORE 3.0 ...

  8. 【HDC.Cloud 2023】华为云区块链分论坛内容值得再读!

    摘要:在Web3时代,基础设施不仅仅是传统意义上的服务器.网络等,还包括了区块链节点.智能合约等,这些基础设施的稳定性和可信度直接影响着Web3的发展. 本文分享自华为云社区<[HDC.Clou ...

  9. 打包 IPA processing failed 失败

    查看报错日志:有些SDK含有x86_64架构,移除即可 1. cd 该库SDK路径下 2.执行 lipo -remove x86_64 BaiduTraceSDK -o BaiduTraceSDK 解 ...

  10. 2023牛客暑期多校训练营5 ABCDEGHI

    比赛链接 A 题解 知识点:莫队,树状数组. 区间询问显然可以离线莫队,考虑端点移动对答案的影响. 不妨先考虑右端点右移一个位置,对答案的改变.假设右端点右移后在 \(r\) ,我们先要知道 \([l ...