Submission #947439

# Submission time Handle Problem Language Result Execution time Memory
947439 2024-03-16T07:21:59 Z vjudge1 Programiranje (COCI17_programiranje) C++14
80 / 80
21 ms 6896 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 1 ms 348 KB Output is correct
3 Correct 1 ms 476 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 18 ms 6780 KB Output is correct
7 Correct 19 ms 6756 KB Output is correct
8 Correct 17 ms 6780 KB Output is correct
9 Correct 17 ms 6896 KB Output is correct
10 Correct 21 ms 6752 KB Output is correct