1 条题解

  • 0
    @ 2023-7-21 12:16:36
    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        int m,l1,r1,l2,r2;
        string s;
        bool flag;
        getline(cin,s);
        cin >> m;
        for (int i = 1;i <= m;i++)
        {
            cin >> l1 >> r1 >> l2 >> r2;
            if (r1 - 1 > s.size() || r2 - 1 > s.size() || l1 > r1 || l2 > r2)
            {
                cout << "No" << endl;
                continue;
            }
            if (l1 == l2 && r1 == r2) 
            {
                cout << "Yes" << endl;
                continue;
            }
            flag = true;
            for (int i = 0;i <= r1 - l1;i++)
            {
                if (s[i + l1 - 1] != s[i + l2 - 1])
                {
                    cout << "No" << endl;
                    flag = false;
                    break;
                }
            }
            if (flag) cout << "Yes" << endl;
        }
    }
    
    • 1

    信息

    ID
    911
    时间
    1000ms
    内存
    128MiB
    难度
    2
    标签
    递交数
    24
    已通过
    21
    上传者