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. 四、流程控制和break、continue、range函数的讲解

    目录 一.流程控制理论和必备基础知识 理论: 必备基础知识: break.continue的用法: 二.流程控制之分支结构 if if...else if...elif...else if的嵌套使用 ...

  2. Vue3源码阅读梳理

    简单代码例子 const { createApp, defineComponent, computed, watch, ref, reactive, effect } = Vue const app ...

  3. 第九周总结-MySQL、前端

    多表查询的两种方式 1.连表操作: 1.1: inner join:内连接,将两张表共同的部分连接在一起生成一张新表.凭借顺序是把后面的表拼在前面表的后面,如果颠倒位置结果不同. select * f ...

  4. python爬取丁香园疫情数据

    毕设需求了就是说 导师要做关于时间线的- -看发展趋势 不得不今天又现学现卖 首先 创建一个python文件 python.file 引入一点资源 # 发送请求 import requests # 页 ...

  5. 使用花生壳进行内网穿透实验SQLserver

    在一次编写软件的过程中,想让远在河南的同学对试一试,但是他的电脑上没有与之对应的SQL数据库不能便不能够运行软件.于是我想到了远程连接.在使用花生壳的时候,遇到了一些问题,然而网络上并没有与之对应的解 ...

  6. Redis 源码解读之 Rehash 的调用时机

    Redis 源码解读之 Rehash 的调用时机 背景和问题 本文想要解决的问题 什么时机触发 Rehash 操作? 什么时机实际执行 Rehash 函数? 结论 什么时机触发 Rehash 操作? ...

  7. 找素数(java)

    什么是素数? 质数又称素数.一个大于1的自然数,除了1和它自身外,不能被其他自然数整除的数叫做质数:否则称为合数(规定1既不是质数也不是合数). 实际案例 比如我们想找出1-1000的所有素数 思路1 ...

  8. 解决veture和eslint冲突的问题

    vscoder自带的veture和eslint存在冲突,主要表现在 末尾逗号,分号,单双引号的不一致.解决办法:1.npm install --save-dev prettier2.在根目录新建.pr ...

  9. JS结束时间与当前时间间隔

    实现内容: 1.时间戳 1587024986952 转成年月日时分秒 2020-04-16 16:16:46 2.当前时间new Date()转成年月日时分秒2019-04-17 10:27:27 3 ...

  10. LeetCode-1609 奇偶树

    来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/even-odd-tree 题目描述 如果一棵二叉树满足下述几个条件,则可以称为 奇偶树 : 二叉 ...