Problem B: 阅读程序-2

Memory Limit:128 MB Time Limit:1.000 S
Judge Style:Text Compare Creator:
Submit:116 Solved:43

Description

#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);

    return 0;

}



假设输入的nm都是正整数,xy都是在[1, n]的范围内的整数,完成下面的判断题和单选题:

 

1)当m>0时,输出的值一定小于2n。()

2)执行完第27行的"++ans"时,ans —定是偶数。()

3)a[i]和b[i]不可能同时大于0。()


4)右程序执行到第13行时,x总是小于y,那么第15行不会被执行。()


5)若m个x两两不同,且m个y两两不同,则输出的值为()


     A. 2n-2m  B. 2n+2  C. 2n-2  D. 2n

6)若m个x两两不同,且m个y都相等,则输出的值为()


     A. 2n-2   B. 2n   C. 2m   D. 2n-2m


Input

输入一个整数n,为题号(1<=n<=6)

Output

输出题目答案,对于判断题,正确的输出字符√,如果错误,输出大写字母X。
对于选择题,输出选项,大写字母。

HINT

示例程序如下:
#include<bits/stdc++.h>
using namespace std;
int main() {
int n; cin>>n;
switch(n) {
case 1: cout<<"√"<<endl; break;
case 2: cout<<"X"<<endl; break;
case 3: cout<<"X"<<endl; break;
case 4: cout<<"X"<<endl; break;
case 5: cout<<"A"<<endl; break;
case 6: cout<<"D"<<endl; break;
}
return 0;
}