A960 | The Great Revegetation--Silver
来源USACO
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
A lengthy drought has left Farmer John's $N$ pastures devoid of grass.
However, with the rainy season arriving soon, the time has come to
"revegetate". In Farmer John's shed, he has two buckets, each with a different
type of grass seed. He wants to plant grass in each of his $N$ pastures,
choosing exactly one type of grass to plant in each.
Being a dairy farmer, Farmer John wants to make sure he manages the somewhat
particular dietary needs of his $M$ cows. Each of his $M$ cows has two
favorite pastures. Some of his cows have a dietary restriction that they
should only eat one type of grass consistently --- Farmer John therefore wants
to make sure the same type of grass is planted in the two favorite fields of
any such cow. Other cows have a very different dietary restriction, requiring
them to eat different types of grass. For those cows, Farmer John of course
wants to make sure their two favorite fields contain different grass types.
Please help Farmer John determine the number of different ways he can plant
grass in his $N$ pastures.
However, with the rainy season arriving soon, the time has come to
"revegetate". In Farmer John's shed, he has two buckets, each with a different
type of grass seed. He wants to plant grass in each of his $N$ pastures,
choosing exactly one type of grass to plant in each.
Being a dairy farmer, Farmer John wants to make sure he manages the somewhat
particular dietary needs of his $M$ cows. Each of his $M$ cows has two
favorite pastures. Some of his cows have a dietary restriction that they
should only eat one type of grass consistently --- Farmer John therefore wants
to make sure the same type of grass is planted in the two favorite fields of
any such cow. Other cows have a very different dietary restriction, requiring
them to eat different types of grass. For those cows, Farmer John of course
wants to make sure their two favorite fields contain different grass types.
Please help Farmer John determine the number of different ways he can plant
grass in his $N$ pastures.
输入格式
The first line of input contains $N$ ($2 \leq N \leq 10^5$) and $M$ ($1 \leq M
\leq 10^5$). Each of the next $M$ lines contains a character that is either
'S' or 'D', followed by two integers in the range $1 \ldots N$, describing the
pair of pastures that are the two favorites for one of Farmer John's cows. If
the character is 'S', this line represents a cow that needs the same type of
grass in its two favorite pastures. If the character is 'D', the line
represents a cow that needs different grass types.
\leq 10^5$). Each of the next $M$ lines contains a character that is either
'S' or 'D', followed by two integers in the range $1 \ldots N$, describing the
pair of pastures that are the two favorites for one of Farmer John's cows. If
the character is 'S', this line represents a cow that needs the same type of
grass in its two favorite pastures. If the character is 'D', the line
represents a cow that needs different grass types.
输出格式
Output the number of ways Farmer John can plant grass in his $N$ pastures.
Please write your answer in binary.
Please write your answer in binary.
输入输出样例
输入 #1
3 2 S 1 2 D 3 2
输出 #1
10
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted