Submission #225207

# Submission time Handle Problem Language Result Execution time Memory
225207 2020-04-19T14:40:21 Z baoduytran0104 Programiranje (COCI17_programiranje) C++14
80 / 80
197 ms 6564 KB
#include <bits/stdc++.h>

using namespace std;
int a[50005][30], n, t, e, b,c , d;
string s;

int main()
{
    cin >> s;
    n = s.size();
    s = ' ' + s;
    for(int i = 1; i <= n; ++i) {
        for(int j = 0; j < 26; ++j) {
            a[i][j] = a[i - 1][j] + (s[i] - 'a' == j);
        }
    }
    cin >> t;
    while(t--) {
        cin >> e >> b >> c >> d;
        if(b - e != d - c) {
            cout << "NE\n";
            continue;
        }
        bool check = 1;
        for(int i = 0; i < 26; ++i) {
            if (a[b][i] - a[e - 1][i] != a[d][i] - a[c - 1][i]) {
                check = 0;
                break;
            }
        }
        cout << (check ? "DA" : "NE") << '\n';
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 384 KB Output is correct
2 Correct 8 ms 384 KB Output is correct
3 Correct 8 ms 384 KB Output is correct
4 Correct 8 ms 384 KB Output is correct
5 Correct 8 ms 512 KB Output is correct
6 Correct 196 ms 6392 KB Output is correct
7 Correct 196 ms 6392 KB Output is correct
8 Correct 195 ms 6496 KB Output is correct
9 Correct 191 ms 6564 KB Output is correct
10 Correct 197 ms 6392 KB Output is correct