Submission #236063

# Submission time Handle Problem Language Result Execution time Memory
236063 2020-05-31T06:15:14 Z VEGAnn Programiranje (COCI17_programiranje) C++14
80 / 80
34 ms 5760 KB
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
using namespace std;
const int N = 50100;
string s;
int n, suf[N][26];

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);

#ifdef _LOCAL
    freopen("in.txt","r",stdin);
#endif // _LOCAL

    cin >> s;

    n = sz(s);

    for (int i = 0; i < 26; i++)
        suf[n][i] = 0;

    for (int i = n - 1; i >= 0; i--){
        for (int j = 0; j < 26; j++)
            suf[i][j] = suf[i + 1][j];

        suf[i][s[i] - 'a']++;
    }

    int qq; cin >> qq;

    for (; qq; qq--){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--; b--; c--; d--;

        bool ok = 1;

        for (int i = 0; i < 26 && ok; i++)
            ok &= bool((suf[a][i] - suf[b + 1][i]) == (suf[c][i] - suf[d + 1][i]));

        cout << (ok ? "DA\n" : "NE\n");
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 34 ms 5632 KB Output is correct
7 Correct 33 ms 5632 KB Output is correct
8 Correct 31 ms 5760 KB Output is correct
9 Correct 33 ms 5752 KB Output is correct
10 Correct 31 ms 5632 KB Output is correct