https://codeforces.com/contest/1795/problem/D

#include <iostream>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
const int N=3e5+10,mod=998244353;
int n;
ll qmi(ll a,ll k){
ll res=1;
while(k){
if(k&1) res=res*a%mod;
k>>=1;
a=a*a%mod;
}
return res;
}
bool fact(int a,int b,int c){
return a==b&&a<c&&b<c;
}
int main(){
ll res=1;
cin>>n;
ll k=1;
for(int i=1;i<=n;i+=3){
int x,y,z;
cin>>x>>y>>z;
if(x==y&&x==z) k=k*3%mod;
else if(fact(x,y,z)||fact(x,z,y)||fact(y,z,x)) k=k*2%mod;
}
for(int i=n/3,j=1;i>n/6;i--,j++){
res=res*i%mod;
res=res*qmi(j,mod-2)%mod;
}
res=res*k%mod;
cout<<res<<endl;
}
/*
就是每三个点一组,给所有数字染色,颜色只有红蓝,且一半染红一半染蓝
要想要使得结果最大
每个三原组有两种染法,红蓝蓝或者蓝红红
我们一共n/3个组,根据对称可得,n/6个得染红蓝蓝
另外有些特殊情况
例如当三个边权都一样时,就有三种情况
当两个边权一样且都是小边权时有两种情况
*/

D. Triangle Coloring的更多相关文章

  1. [LeetCode] Triangle 三角形

    Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent n ...

  2. [LeetCode] Pascal's Triangle II 杨辉三角之二

    Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Return [1,3, ...

  3. [LeetCode] Pascal's Triangle 杨辉三角

    Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Retur ...

  4. 【leetcode】Pascal's Triangle II

    题目简述: Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Retur ...

  5. 【leetcode】Pascal's Triangle

    题目简述: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5 ...

  6. POJ 1163 The Triangle(简单动态规划)

    http://poj.org/problem?id=1163 The Triangle Time Limit: 1000MS   Memory Limit: 10000K Total Submissi ...

  7. Triangle - Delaunay Triangulator

    Triangle - Delaunay Triangulator  eryar@163.com Abstract. Triangle is a 2D quality mesh generator an ...

  8. LeetCode 118 Pascal's Triangle

    Problem: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows  ...

  9. LeetCode 119 Pascal's Triangle II

    Problem: Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Ret ...

  10. 【leetcode】Triangle (#120)

    Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent n ...

随机推荐

  1. 判断一个对象是否是数组的n个方法,typeOf不能判断引用类型对象

  2. Axure 列表左右滑动交互-删除、置顶

    Axure 列表左右滑动交互 左滑:删除.标记 右滑:置顶.回复 拖一个动态面板,命名为[滑动面板],添加三个状态,并分别命名为:正常状态.向左状态.向右状态 添加元件 正常状态 向左状态 将[正常状 ...

  3. Sundial(一)

    Sundial 源码梳理 - v2.5.6 代码目录一览 通过入口点说明 实现IServiceCollection,并返回IServiceCollection(Extensions/ScheduleS ...

  4. EL&JSTL笔记 javaweb+jdbcTempl

    # 今日内容    1. JSP:        1. 指令        2. 注释        3. 内置对象    2. MVC开发模式    3. EL表达式    4. JSTL标签   ...

  5. IOS + H5 开发,如何实现,H5页面显示在IOS上

    环境:IOS12.0 工具:Xcode 12.0 工程:IOS12.0工程 + H512.0工程 1,先把开发的H5画面,编译打包:assets静态资源文件 favicon.ico图标 index.h ...

  6. 关于vue项目和内嵌iframe页面之间的通信问题

    最近项目中遇到一个与内嵌iframe页面之间通信的问题,起初与原生之间通信很简单,没想到过与vue项目通信的问题,霎时间一脸懵*啊,百度了一下,原来是那么简单,这里记录下以供下次参考 //vue页面 ...

  7. ORACLE数据库相关操作

    表操作 -- 截断表 TRUNCATE TABLE TABLE_NAME; -- 删除表 DROP TABLE TABLE_NAME; -- 查询表 SELECT * FROM TABLE_NAME; ...

  8. C4模型,架构设计图的脚手架,你值得拥有

    hi,我是熵减,见字如面. 对于软件开发团队来说,写软件设计文档,花架构图,是日常工作中的关键一项. 而其中,如何画好系统设计的架构图呢? Simon Brown 就 提出 C4 模型,来解决这个问题 ...

  9. Vulhub 漏洞学习之:ActiveMQ

    Vulhub 漏洞学习之:ActiveMQ 目录 Vulhub 漏洞学习之:ActiveMQ 1 ActiveMQ反序列化漏洞(CVE-2015-5254): 1.1 漏洞利用过程 2 ActiveM ...

  10. CF846F - Random Query

    题意:对于一个序列,每次随机选择两个数 \(l,r\),如果 \(l\gt r\) 就交换,求 \(l,r\) 中本质不同的数个数的期望. 我们发现,在所有的 \(n^2\) 个选择方案中,其实就是 ...