How Many Answers Are Wrong
来源:互联网 发布:肌肉型小腿如何瘦 知乎 编辑:程序博客网 时间:2024/06/05 10:40
TT and FF are ... friends. Uh... very very good friends -________-b
FF is a bad boy, he is always wooing TT to play the following game with him. This is a very humdrum game. To begin with, TT should write down a sequence of integers-_-!!(bored).
Then, FF can choose a continuous subsequence from it(for example the subsequence from the third to the fifth integer inclusively). After that, FF will ask TT what the sum of the subsequence he chose is. The next, TT will answer FF's question. Then, FF can redo this process. In the end, FF must work out the entire sequence of integers.
Boring~~Boring~~a very very boring game!!! TT doesn't want to play with FF at all. To punish FF, she often tells FF the wrong answers on purpose.
The bad boy is not a fool man. FF detects some answers are incompatible. Of course, these contradictions make it difficult to calculate the sequence.
However, TT is a nice and lovely girl. She doesn't have the heart to be hard on FF. To save time, she guarantees that the answers are all right if there is no logical mistakes indeed.
What's more, if FF finds an answer to be wrong, he will ignore it when judging next answers.
But there will be so many questions that poor FF can't make sure whether the current answer is right or wrong in a moment. So he decides to write a program to help him with this matter. The program will receive a series of questions from FF together with the answers FF has received from TT. The aim of this program is to find how many answers are wrong. Only by ignoring the wrong answers can FF work out the entire sequence of integers. Poor FF has no time to do this job. And now he is asking for your help~(Why asking trouble for himself~~Bad boy)
FF is a bad boy, he is always wooing TT to play the following game with him. This is a very humdrum game. To begin with, TT should write down a sequence of integers-_-!!(bored).
Then, FF can choose a continuous subsequence from it(for example the subsequence from the third to the fifth integer inclusively). After that, FF will ask TT what the sum of the subsequence he chose is. The next, TT will answer FF's question. Then, FF can redo this process. In the end, FF must work out the entire sequence of integers.
Boring~~Boring~~a very very boring game!!! TT doesn't want to play with FF at all. To punish FF, she often tells FF the wrong answers on purpose.
The bad boy is not a fool man. FF detects some answers are incompatible. Of course, these contradictions make it difficult to calculate the sequence.
However, TT is a nice and lovely girl. She doesn't have the heart to be hard on FF. To save time, she guarantees that the answers are all right if there is no logical mistakes indeed.
What's more, if FF finds an answer to be wrong, he will ignore it when judging next answers.
But there will be so many questions that poor FF can't make sure whether the current answer is right or wrong in a moment. So he decides to write a program to help him with this matter. The program will receive a series of questions from FF together with the answers FF has received from TT. The aim of this program is to find how many answers are wrong. Only by ignoring the wrong answers can FF work out the entire sequence of integers. Poor FF has no time to do this job. And now he is asking for your help~(Why asking trouble for himself~~Bad boy)
Line 2..M+1: Line i+1 contains three integer: Ai, Bi and Si. Means TT answered FF that the sum from Ai to Bi is Si. It's guaranteed that 0 < Ai <= Bi <= N.
You can assume that any sum of subsequence is fit in 32-bit integer.
10 51 10 1007 10 281 3 324 6 416 6 1
1
题意:找错误的区间值有几个。
#include<cstdio>#include<cmath>#include<cstring>#include<iostream>#include<algorithm>using namespace std;int father[200001];int weight[200001];int n,m,a,b,c,sum;void intl(){ for(int i=0;i<=n;i++) { father[i]=i; weight[i]=0; } }int find(int x){ if(x==father[x]) return x; else { int kk=find(father[x]); weight[x]+=weight[father[x]]; father[x]=kk; return father[x]; }}void unin(int x,int y,int c){ int nx=find(x); int ny=find(y); if(nx==ny) { if(weight[y]-weight[x]!=c) sum++; } else { father[nx]=ny; weight[nx]=weight[y]-weight[x]-c; }}int main(){ while(~scanf("%d%d",&n,&m)) { intl(); sum=0; for(int i=1;i<=m;i++) { scanf("%d%d%d",&a,&b,&c); a--; unin(a,b,c); } printf("%d\n",sum); }}
阅读全文
0 0
- How Many Answers Are Wrong
- How Many Answers Are Wrong
- How Many Answers Are Wrong
- How Many Answers Are Wrong
- How Many Answers Are Wrong
- HDU 3038 How Many Answers Are Wrong
- HDU 3038 How Many Answers Are Wrong
- hdoj 3038 How Many Answers Are Wrong
- hdu3038 How Many Answers Are Wrong
- hdu 3038 How Many Answers Are Wrong
- hdu 3038 How Many Answers Are Wrong
- HDU3038 How Many Answers Are Wrong
- HDU 3038 How Many Answers Are Wrong
- HDU-3038-How Many Answers Are Wrong
- HDU How Many Answers Are Wrong
- HDOJ 3038 How Many Answers Are Wrong
- hdu 3038 How Many Answers Are Wrong
- HDU 3038 How Many Answers Are Wrong
- JAVA编程练习
- rpm -e 惊魂夜
- 线程与线程池的实验与使用
- 机器学习与深度学习(四) 神经网络 (Neural Network) NN
- emmc FITRIM/discard命令在android系统中提升write performance的运用
- How Many Answers Are Wrong
- springMVC—拦截器的实现登录控制
- 监听器Listener汇总
- spring boot热部署
- 三张表user,user2,user3结构相同,找出user表中与user2,user3表不相同的数据。
- 【算法】图的应用之求两个城市间的最短路径--FloydWarshall算法
- BZOJ 1086 王室联邦 树分块
- PAT乙级 1021. 个位数统计 (15)
- jsp中的4个作用范围