bzoj1603: [Usaco2008 Oct]打谷机 (纱布题)

时间:2023-03-10 01:05:50
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;
}
×

真诚赞赏,手留余香

2元
5元
10元
50元
100元
任意金额
2元

使用微信扫描二维码完成支付

bzoj1603: [Usaco2008 Oct]打谷机 (纱布题)

bzoj1603: [Usaco2008 Oct]打谷机 (纱布题)
bzoj1603: [Usaco2008 Oct]打谷机 (纱布题)

Please enable JavaScript to view the comments powered by Disqus.
comments powered by Disqus