题库 信息学奥赛题库 题目列表 2020年CSP-S提高组初赛阅读程序:#include <i...
组合题

2020年CSP-S提高组初赛阅读程序:

#include <iostream>
#include <queue>
using namespace std;
const int maxl = 20000000;
class Map {
    struct item {
        string key; int value;
    } d[maxl];
    int cnt;
  public:
    int find(string x) {
        for (int i = 0; i < cnt; ++i)
            if (d[i].key == x)
                return d[i].value;
        return -1;
    }
    static int end() { return -1; }
    void insert(string k, int v) {
        d[cnt].key = k; d[cnt++].value = v;
    }
} s[2];
class Queue {
    string q[maxl];
    int head, tail;
  public:
    void pop() { ++head; }
    string front() { return q[head + 1]; }
    bool empty() { return head == tail; }
    void push(string x) { q[++tail] = x;  }
} q[2];
string st0, st1;
int m;
string LtoR(string s, int L, int R) {
    string t = s;
    char tmp = t[L];
    for (int i = L; i < R; ++i)
        t[i] = t[i + 1];
    t[R] = tmp;
    return t;
}
string RtoL(string s, int L, int R) {
    string t = s;
    char tmp = t[R];
    for (int i = R; i > L; --i)
        t[i] = t[i - 1];
    t[L] = tmp;
    return t;
}
bool check(string st , int p, int step) {
    if (s[p].find(st) != s[p].end())
        return false;
    ++step;
    if (s[p ^ 1].find(st) == s[p].end()) {
        s[p].insert(st, step);
        q[p].push(st);
        return false;
    }
    cout << s[p ^ 1].find(st) + step << endl;
    return true;
}

第1题 判断

输出可能为0。( )

A.
正确
B.
错误
第2题 判断

若输入的两个字符串长度均为 101 时,则 m=0 时的输出与 m=100 时的输出是一样的。( )

A.
正确
B.
错误
第3题 判断

若两个字符串的长度均为 n,则最坏情况下,此程序的时间复杂度为 O(n!)。( )

A.
正确
B.
错误
第4题 单选

若输入的第一个字符串长度由 100 个不同的字符构成,第二 个字符串是第一个字符串的倒序,输入的 m 为 0,则输出为( )。

A.

49

B.

50

C.

100

D.

-1

第5题 单选

己知当输入为“ 0123\n3210\n1” 时输出为 4,当输入为 “012345\n543210\n1” 时输出为14,当输入为 “01234567\n76543210\n1 ”时输出为 28,则当输入为“0123456789ab\nba9876543210\nl” 输出为( )。其中 \n 为换行符。

A.

56

B.

84

C.

102

D.

68

第6题 单选

若两个字符串的长度均为 n,且 0<m<n-l,且两个字符串的构成相同(即任何一个字符在两个字符串中出现的次数均相同),则下列说法正确的是( )。提示:考虑输入与输出有多少对字符前后顺序不一样。

A.

若 n、m 均为奇数,则输出可能小于 0。

B.

若 n、m 均为偶数,则输出可能小于 0。

C.

若 n 为奇数、m 为偶数,则输出可能小于 0。

D.

若 n 为偶数、m 为奇数,则输出可能小于 0。

题目信息
阅读程序 初赛 2020年
-
正确率
0
评论
115
点击