博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Zjnu Stadium
阅读量:5156 次
发布时间:2019-06-13

本文共 2430 字,大约阅读时间需要 8 分钟。

Zjnu Stadium

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 1996    Accepted Submission(s): 762

Problem Description
In 12th Zhejiang College Students Games 2007, there was a new stadium built in Zhejiang Normal University. It was a modern stadium which could hold thousands of people. The audience Seats made a circle. The total number of columns were 300 numbered 1--300, counted clockwise, we assume the number of rows were infinite.
These days, Busoniya want to hold a large-scale theatrical performance in this stadium. There will be N people go there numbered 1--N. Busoniya has Reserved several seats. To make it funny, he makes M requests for these seats: A B X, which means people numbered B must seat clockwise X distance from people numbered A. For example: A is in column 4th and X is 2, then B must in column 6th (6=4+2).
Now your task is to judge weather the request is correct or not. The rule of your judgement is easy: when a new request has conflicts against the foregoing ones then we define it as incorrect, otherwise it is correct. Please find out all the incorrect requests and count them as R.
 

 

Input
There are many test cases:
For every case: 
The first line has two integer N(1<=N<=50,000), M(0<=M<=100,000),separated by a space.
Then M lines follow, each line has 3 integer A(1<=A<=N), B(1<=B<=N), X(0<=X<300) (A!=B), separated by a space.
 

 

Output
For every case: 
Output R, represents the number of incorrect request.
 

 

Sample Input

10 10

1 2 150
3 4 200
1 5 270
2 6 200
6 5 80
4 7 150
8 9 100
4 8 50
1 7 100
9 2 100

Sample Output
2
Hint
Hint: (PS: the 5th and 10th requests are incorrect)
 

 

Source
 代码:
1 #include 
2 #include
3 #include
4 #include
5 using namespace std; 6 int Sum[200005];/*表示父节点到该点的距离*/ 7 int ID[200005]; 8 void Cread_(int N) 9 {10 for(int i=0;i<=N;i++)11 {12 Sum[i]=0;13 ID[i]=i;14 }15 return ;16 }17 int Find_Son(int x)18 {19 int tmp,p=x;20 if(ID[x]!=x)21 {22 tmp=Find_Son(ID[x]);23 Sum[x]+=Sum[ID[x]];24 }25 else tmp=x;26 ID[x]=tmp;27 return tmp;28 }29 30 int main()31 {32 int N,M,i,j,k,a,b,c,A,B;33 while(scanf("%d%d",&N,&M)!=EOF)34 {35 Cread_(N);36 int SIGN=0;37 for(i=0;i
View Code

 

转载于:https://www.cnblogs.com/Wurq/articles/4543049.html

你可能感兴趣的文章
淌淌淌
查看>>
win10每次开机都显示“你的硬件设置已更改,请重启电脑……”的解决办法
查看>>
C++有关 const & 内敛 & 友元&静态成员那些事
查看>>
函数积累
查看>>
Swift 入门之简单语法(六)
查看>>
〖Python〗-- IO多路复用
查看>>
栈(括号匹配)
查看>>
Java学习 · 初识 面向对象深入一
查看>>
源代码如何管理
查看>>
vue怎么将一个组件引入另一个组件?
查看>>
bzoj1040: [ZJOI2008]骑士
查看>>
LeetCode 74. Search a 2D Matrix(搜索二维矩阵)
查看>>
利用SignalR来同步更新Winfrom
查看>>
反射机制
查看>>
CocoaPod
查看>>
BZOJ 1251: 序列终结者 [splay]
查看>>
5G边缘网络虚拟化的利器:vCPE和SD-WAN
查看>>
MATLAB基础入门笔记
查看>>
【UVA】434-Matty&#39;s Blocks
查看>>
Android开发技术周报 Issue#80
查看>>