2 条题解

  • 0
    @ 2024-9-8 19:06:18

    J1B What beats RiOI

    思路

    RiOI 这个字符串较短,打表出每一种可能的大小写情况,遍历时用 find 函数判断即可。

    复杂度

    s|s| 为字符串 ss 的长度。

    时间复杂度:

    O(x+y)O(|x|+|y|)

    空间复杂度:

    O(x+y)O(|x|+|y|)

    Code

    #include <bits/stdc++.h>
    using namespace std;
    int pd(string a)
    {
    	string b[105] = {"rioi","Rioi","rIoi","riOi","rioI","RIoi","RiOi","RioI","rIOi","rIoI","riOI","RIOi","rIOI","RIoI","RiOI","RIOI"};
    	for (int i = 0;i < 15;i++)
    	{
    		if (a.find(b[i]) != -1) return 1;
    	}
    	return 0;
    }
    int main()
    {
    	string a,b;
    	cin >> a >> b;
    	int x = pd(a),y = pd(b);
    	if (x && y) cout << "Either is ok!";
    	else if (x) cout << a << " for sure!";
    	else if (y) cout << b << " for sure!";
    	else cout << "Try again!";
    	return 0;
    }
    

    信息

    ID
    47
    时间
    1000ms
    内存
    512MiB
    难度
    1
    标签
    递交数
    274
    已通过
    204
    上传者