# *hdu3047 and check Set

Source: Internet
Author: User

Time limit:2000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 3062 Accepted Submission (s): 1182

Problem DescriptionIn 12th Zhejiang College Students Games, there is a new stadium built in Zhejiang Normal universi Ty. It is a modern stadium which could hold thousands of people. The audience seats made a circle. The total number of columns were 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'll be N people go there numbered 1--n. Busoniya have 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 are in column 4th and X are 2, then B must in column 6th (6=4+2).
Now your task was to judge weather the request was correct or not. The rule of your judgement is easy:when a new request have conflicts against the foregoing ones then we define it as Incor Rect, otherwise it is correct. Please find the incorrect requests and count them as R.

Inputthere is many test cases:
For every case:
The first line has both integer N (1<=n<=50,000), M (0<=m<=100,000), separated by a space.
Then M. lines follow, each line has 3 integers a (1<=a<=n), B (1<=b<=n), X (0<=x<300) (a!=b), separated by A Space.

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

Sample Input10 101 2 1503 4 2001 5 2702 6 2006 5 804 7 1508 9 1004 8 501 7 1009 2 100

Sample Output2 HintHint: (ps:the 5th and 10th requests are incorrect)

Source multi-university Training Contest 14-host by ZJNU test instructions: In a ring with a circumference of 300, a total of n points, each given a clockwise distance between two points, asked in the previous given data conditions whether the new data given Correct, count the number of errors. Code:

`1 //Num[b]=num[x]+z-num[y] This look at the picture is good to understand2#include <iostream>3#include <cstdio>4#include <cstring>5#include <cmath>6 using namespacestd;7 intn,m;8 intfat[50004];9 intnum[50004];Ten intFindintx) One { A     if(fat[x]!=x) -     { -         intf=Fat[x]; thefat[x]=find (Fat[x]); -num[x]+=Num[f]; -     } -     returnFat[x]; + } - voidConnectintXintYintz) + { A     intA=find (x), b=find (y); at     if(a!=b) -     { -fat[b]=A; -num[b]=num[x]+z-Num[y]; -     } - } in intMain () - { to     intA,b,c,ans; +      while(SCANF ("%d%d", &n,&m)! =EOF) -     { theans=0; *          for(intI=0; i<=n;i++) \$         {Panax Notoginsengfat[i]=i; -num[i]=0; the         } +          for(intI=1; i<=m;i++) A         { thescanf"%d%d%d",&a,&b,&c); +             if(Find (a) = =find (b)) -             { \$                 if(num[b]-num[a]!=c) \$ans++; -             } -             ElseConnect (a,b,c); the         } -printf"%d\n", ans);Wuyi     } the     return 0; -}`

*hdu3047 and check Set

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.