首页 > 其他分享 >[AGC043C] Giant Graph

[AGC043C] Giant Graph

时间:2023-12-16 20:01:32浏览次数:25  
标签:10 Giant const int Graph AGC043C SG operatorname

[AGC043C] Giant Graph

这题真的抽象。

注意到 \(10^{18} > n^3\),因此只需按照 \(x+y+z\) 从大到小贪心,由于每次选点只会影响到下面若干层点的可选性,所以可以直接能选就选。时间复杂度 \(O(n^3)\)。

考虑优化,刻画一个点 \((x,y,z)\) 能选中的充要条件,即它的所有前驱都没有被选中。联想到博弈论,令可以选中的点为必败态,那么答案就是所有必败态的权值和。

关于博弈论,我们有什么武器呢?没错——\(\operatorname{SG}\) 函数。注意到三维互不影响,所以这实际上是一个简单组合游戏,可以把单个游戏的 \(\operatorname{SG}\) 函数求出来然后直接取异或和得到整个游戏的 \(\operatorname{SG}\) 函数。这样,我们把式子拆开,就变成了

\[\sum_{\operatorname{SG}_1(x) \oplus \operatorname{SG}_2(y) \oplus \operatorname{SG}_3(z) = 0} 10^{18(x+y+z)} \]

这个东西是异或卷积的形式可以直接做。当然也可以注意到 \(\operatorname{SG}\) 函数的值域是根号级别然后直接枚举 \(\operatorname{SG}\) 函数值来算。

const LL P = 998244353;

const int N = 1e5 + 10;
const int B = 500;
int n;
int f[B + 10], g[B + 10], h[B + 10]; 
LL val[N];

void add(int &x, int y) {
  (x += y) >= P ? x -= P : 0;
}

vector<int> G[N];
int sg[N], m;
void solve(int *f) {
  read(m);
  for(int i = 1; i <= n; ++i)
    G[i].clear(), sg[i] = 0;
  for(int i = 1; i <= m; ++i) {
    int u, v; read(u, v);
    if(u > v) swap(u, v);
    G[u].eb(v);
  }
  for(int i = n; i >= 1; --i) {
    set<int> s;
    for(int j : G[i])
      s.insert(sg[j]);
    for(int j = 0; j <= B; ++j)
      if(s.find(j) == s.end()) {
        sg[i] = j;
        break;
      }
    add(f[sg[i]], val[i]);
  }
}

int main() {
  read(n);
  val[0] = 1, val[1] = (LL)1e18 % P;
  for(int i = 2; i <= n; ++i)
    val[i] = val[i - 1] * val[1] % P;
  solve(f), solve(g), solve(h);
  int ans = 0;
  for(int i = 0; i <= B; ++i)
    for(int j = 0; j <= B; ++j)
      add(ans, 1ll * f[i] * g[j] % P * h[i ^ j] % P);
  printf("%d\n",ans);
}

标签:10,Giant,const,int,Graph,AGC043C,SG,operatorname
From: https://www.cnblogs.com/DCH233/p/17907246.html

相关文章

  • 何时使用GraphQL、gRPC 和 REST
    何时使用GraphQL、gRPC和REST     在设计应用程序时,开发人员可以从各种客户端-服务器通信协议中进行选择。使用GraphQL、gRPC和REST在当代项目中相对常见。每种协议都可以提供各种优势,具体取决于您的应用需求。      一.GraphQL是一种灵活的数据请求方法,它专......
  • 智能计算与图形图像处理Intelligent Computing and Graphics and Image Processing
      智能算法IntelligenceAlgorithms图形图像处理Graphics&ImageProcessing机器视觉machinevision计算机视觉computervision 计算机视觉(computervision),用计算机来模拟人的视觉机理获取和处理信息的能力。就是是指用摄影机和电脑代替人眼对......
  • 【graphviz笔记】用graphviz画UML类图
    digraphUMLClassDiagram{//指定节点类型,这样节点才会变成UML的类图矩形node[shape=record,fontname="Arial"];//定义节点数据//其中“|”会渲染成横线;//\l表示向左对齐,同时换行//\n表示居中对齐,同时换行class1[label="{ Class1 | +attribute1:type\l +me......
  • dgl AttributeError: Can't get attribute 'DGLGraph' on <module 'dgl.heterograp
    由于服务器重装了系统,因此cuda版本和ubuntu系统版本也换了,不得不重装系统,导致以前可以正常运行的代码出了各种故障(注:现在的ubuntu版本是18.04,cuda版本是11.3)AttributeError:Can'tgetattribute'DGLGraph'on<module'dgl.heterograph'from'/home/user/anaconda3/envs/mymod......
  • 论文笔记: Attributed Graph Clustering: A Deep Attentional Embedding Approach
    论文笔记:AttributedGraphClustering:ADeepAttentionalEmbeddingApproach中文名称:属性图聚类:一种深度注意力嵌入方法论文链接:https://arxiv.org/abs/1906.06532背景:​ 图聚类是发现网络中的社区或群体的一项基本任务。最近的研究主要集中在开发深度学习方......
  • Adaptive Graph Contrastive Learning for Recommendation论文阅读笔记
    Abstract在实际的场景中,用户的行为数据往往是有噪声的,并且表现出偏态分布。所以需要利用自监督学习来改善用户表示。我们提出了一种新的自适应图对比学习(AdaGCL)框架,该框架使用两个自适应对比视图生成器来进行数据增强,以更好地增强CF范式。具体的说,我们使用了两个可训练的视图生......
  • 解密 ArcGraph 分布式一致性:Raft 协议与分布式事务实现丨技术专栏
    导读:本文提出了一种将事务日志和Raft日志融合在一起的机制,从而实现了分布式事务和数据一致性的场景。01背景介绍分布式系统是伴随着互联网的高速发展而出现的。其出现为了应对单机系统无法解决的高并发、高可用性、容错性等问题。分布式系统将传统的系统扩容模式,从scaleup......
  • Graph regularized non-negative matrix factorization with prior knowledge consist
    Graphregularizednon-negativematrixfactorizationwithpriorknowledgeconsistencyconstraintfordrug-targetinteractionspredictionJunjunZhang 1, MinzhuXie 2 3Affiliations expandPMID: 36581822 PMCID: PMC9798666 DOI: 10.1186/s1285......
  • Drug response prediction using graph representation learning and Laplacian featu
    DrugresponsepredictionusinggraphrepresentationlearningandLaplacianfeatureselectionMinzhuXie 1 2, XiaowenLei 3, JianchenZhong 3, JianxingOuyang 3, GuijingLi 3Affiliations expandPMID: 36494630 PMCID: PMC9733001 DOI: ......
  • Graph regularized non-negative matrix factorization with [Formula: see text] nor
    Graphregularizednon-negativematrixfactorizationwith[Formula:seetext]normregularizationtermsfordrug-targetinteractionspredictionJunjunZhang 1, MinzhuXie 2 3Affiliations expandPMID: 37789278 PMCID: PMC10548602 DOI: 10.11......