Submission #947474

# Submission time Handle Problem Language Result Execution time Memory
947474 2024-03-16T08:59:36 Z vjudge1 Programiranje (COCI17_programiranje) C++17
80 / 80
15 ms 5976 KB
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
using ll = long long;
const int maxN = 5e4 + 1;   
const int MOD = 1e9 + 7;

string s;
int n, q, pre[maxN][26];

void ReadInput()
{
    cin >> s;
    n = s.size();
    s = " " + s;
}

void Solve()
{
    for (int i = 1; i <= n; i++)
    {
        pre[i][s[i] - 'a']++;
        for (int j = 0; j < 26; j++)
            pre[i][j] += pre[i - 1][j];
    }

    int A, B, C, D;
    cin >> q;
    while (q--)
    {
        cin >> A >> B >> C >> D;
        bool flag = true;
        for (int j = 0; j < 26; j++)
            if (pre[B][j] - pre[A - 1][j] != pre[D][j] - pre[C - 1][j])
            {
                flag = false;
                break;
            }
        if (flag) cout << "DA\n";
        else cout << "NE\n";
    }
}

#define task ""
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen(task".INP", "r", stdin);
    //freopen(task".OUT", "w", stdout);
    int T = 1;
    //cin >> T;
    while (T--)
    {
        ReadInput();
        Solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 15 ms 5724 KB Output is correct
7 Correct 15 ms 5976 KB Output is correct
8 Correct 15 ms 5724 KB Output is correct
9 Correct 15 ms 5720 KB Output is correct
10 Correct 15 ms 5720 KB Output is correct