1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #include <cstdio> using namespace std; int n,m; int a[100],b[100]; int main(){ scanf("%d%d",&n,&m); for (int i = 1; i <=n; i++) a[i]=b[i]=0; for (int i = 1; i <=m; i++){ int x,y; scanf("%d%d",&x,&y); if(a[x]<y&&b[y]<x){ if(a[x]>0) b[a[x]]=0; if(b[y]>0) a[b[y]]=0; a[x]=y; b[y]=x; } } int ans=0; for (int i = 1; i <=n; i++) { if(a[i]==0) ++ans; if(b[i]==0) ++ans; } printf("%d",ans); } |
0 of 6 Questions completed
Questions:
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
0 of 6 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
1.当m>0时,输出的值一定小于2n( )
2.执行完第27行的"++ans"时,ans一定是个偶数。( )
3. a[i]和b[i]不可能同时大于0。
4. 若程序执行到第13行时,x总是小于y,那么第15行不会被执行。
5. 若m个x两两不同,且m个y两两不同,则输出的值为( )
若m个x两两不同,且m个y都相等,则输出的值为( )