bzoj1603: [Usaco2008 Oct]打谷机 (纱布题)
Time Limit: 5 Sec Memory Limit: 64 MB
Submit: 774 Solved: 593
[Submit][Status][Discuss]
Description
Farmer John有一个过时的打谷机(收割小麦),它需要带子来带动。发动机驱动轮1总是顺时针旋转的,用来带动转轮2,转轮2来带动转轮3,等等。一共有n(2<=n<=1000)个转轮(n-1条带子)。上面的图解描述了转轮的两种连接方式,第一种方式使得两个轮子旋转的方向相同,第二种则相反。 给出一串带子的信息: *Si—驱动轮 *Di—被动轮 *Ci—连接的类型(0=直接连接,1=交叉连接) 不幸的是,列出的信息是随即的。 作为样例,考虑上面的图解,n=4,转轮1是驱动轮,可以得知最后转轮4是逆时针旋转的。
Input
*第一行:一个数n *第二行到第n行:每一行有三个被空格隔开的数:Si,Di,Ci
Output
*第一行:一个单独的数,表示第n个转轮的方向,0表示顺时针,1表示逆时针。
Sample Input
4
2 3 0
3 4 1
1 2 0
Sample Output
1
思路:傻逼模拟题。。。。排下序。
/* ***********************************************
Author :111qqz
Created Time :2016年03月31日 星期四 21时04分09秒
File Name :code/bzoj/1603.cpp
************************************************ */
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#define fst first
#define sec second
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define ms(a,x) memset(a,x,sizeof(a))
typedef long long LL;
#define pi pair < int ,int >
#define MP make_pair
using namespace std;
const double eps = 1E-8;
const int dx4[4]={1,0,0,-1};
const int dy4[4]={0,-1,1,0};
const int inf = 0x3f3f3f3f;
const int N=1005;
int n;
struct node
{
int s,d,c;
bool operator < (node b)const
{
return s<b.s;
}
}a[N];
int main()
{
#ifndef ONLINE_JUDGE
freopen(&# 大专栏 bzoj1603: [Usaco2008 Oct]打谷机 (纱布题)34;code/in.txt","r",stdin);
#endif
cin>>n;
for ( int i = 1 ; i <= n-1 ; i ++) cin>>a[i].s>>a[i].d>>a[i].c;
sort(a+1,a+n);
int flag = 0;
for ( int i = 1 ;i <= n-1 ; i++)
{
if (a[i].c==1) flag^=1;
}
cout<<flag<<endl;
#ifndef ONLINE_JUDGE
fclose(stdin);
#endif
return 0;
}
真诚赞赏,手留余香
5元
10元
50元
100元
任意金额
使用微信扫描二维码完成支付


Please enable JavaScript to view the comments powered by Disqus.
comments powered by Disqus
bzoj1603: [Usaco2008 Oct]打谷机 (纱布题)的更多相关文章
- BZOJ1603: [Usaco2008 Oct]打谷机
1603: [Usaco2008 Oct]打谷机 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 602 Solved: 458[Submit][Stat ...
- BZOJ 1603: [Usaco2008 Oct]打谷机
题目 1603: [Usaco2008 Oct]打谷机 Time Limit: 5 Sec Memory Limit: 64 MB Description Farmer John有一个过时的打谷机( ...
- 【BZOJ】1603: [Usaco2008 Oct]打谷机(水题+dfs)
http://www.lydsy.com/JudgeOnline/problem.php?id=1603 这种水题... dfs没话说.. #include <cstdio> #inclu ...
- BZOJ 1603 [Usaco2008 Oct]打谷机 dfs
题意:id=1603">链接 方法:暴力 解析: 搜1到n路径上的边权异或和-. 这几个水题刷的我有点-.. 代码: #include <cstdio> #include ...
- bzoj 1603: [Usaco2008 Oct]打谷机【瞎搞】
一棵树,碰到改变转向的边就异或一下,从1dfs一遍 #include<iostream> #include<cstdio> using namespace std; const ...
- [BZOJ1601][Usaco2008 Oct]灌水 最小生成树水题
1601: [Usaco2008 Oct]灌水 Time Limit: 5 Sec Memory Limit: 162 MBSubmit: 2121 Solved: 1393[Submit][St ...
- BZOJ 1603 USACO 2008 Oct. 打谷机
[题解] 水题.. 保存连接方式,按顺序处理即可. #include<cstdio> #include<algorithm> using namespace std; int ...
- BZOJ 1602: [Usaco2008 Oct]牧场行走 倍增裸题
Description N头牛(2<=n<=1000)别人被标记为1到n,在同样被标记1到n的n块土地上吃草,第i头牛在第i块牧场吃草. 这n块土地被n-1条边连接. 奶牛可以在边上行走, ...
- BZOJ 1600: [Usaco2008 Oct]建造栅栏
1600: [Usaco2008 Oct]建造栅栏 Time Limit: 5 Sec Memory Limit: 64 MB Description 勤奋的Farmer John想要建造一个四面的 ...
随机推荐
- 蓝桥杯 sine之舞(递归)
Description 最近FJ为他的奶牛们开设了数学分析课,FJ知道若要学好这门课,必须有一个好的三角函数基本功.所以他准备和奶牛们做一个“Sine之舞”的游戏,寓教于乐,提高奶牛们的计算能力.不妨 ...
- maven多模块profiles的石使用
另外参考:https://blog.csdn.net/linhao19891124/article/details/73872303 maven中指定build一个project中几个特定的子modu ...
- BeagleboneBlack上u-boot的MLO文件是哪里来的
在玩BeagleboneBlack一段时间之后不可避免地接触到了u-boot,之前的玩耍过程大致上是这样的: 在MATLAB下耍,因为MATLAB提供了它的硬件支持,可以直接在命令行与之交互,也可在s ...
- 56)PHP,模型类的设计思想
一张表对应一个模型类-----Mode
- PAT甲级——1041 Be Unique
1041 Be Unique Being unique is so important to people on Mars that even their lottery is designed in ...
- python语法基础-并发编程-线程-长期维护
############### 线程和GIL,全局解释器锁 ############## """ 线程 为什么会有进程? 主要是能够同时处理多个任务,多个任务还 ...
- 关于Java中反射的总结
Java是面向对象的编程语言,万物皆对象,反射技术就是把类声明.类中的字段声明.方法声明.构造函数声明等都看成是对象,从而可以把类中的各个部分拆解出来单独处理,反射技术主要用来编写通用功能,平时编程使 ...
- Socket设置超时时间
主要有以下两种方式,我们来看一下方式1: Socket s=new Socket(); s.connect(new InetSocketAddress(host,port),10000); 方式2: ...
- Mybatis的generator自动生成代码
mybatis-generator有三种用法:命令行.ide插件.maven插件.本次使用maven生成 环境:IDEA,mysql8,maven (1):新建项目,本次以SpringBoot项目为例 ...
- [LC] 211. Add and Search Word - Data structure design
Design a data structure that supports the following two operations: void addWord(word) bool search(w ...