#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2e5 + 5;
string s;
int cnt[26][N], n, q ;
int32_t main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> s ; n = s.size() ;
s = '#' + s;
for (int i = 1 ; i <= n ; i++) {
cnt[s[i] - 'a'][i] = 1 ;
}
for (int i = 0 ; i < 26 ; i++) {
for (int j = 1 ; j <= n ; j++) {
cnt[i][j] += cnt[i][j - 1] ;
}
}
cin >> q ;
while (q--) {
int a, b, c, d; cin >> a >> b >> c >> d ;
bool ok = 1 ;
for (int i = 0 ; i < 26 ; i++) {
bool x = cnt[i][b] - cnt[i][a - 1] ;
bool y = cnt[i][d] - cnt[i][c - 1] ;
ok &= (x == y) ;
}
cout << (ok ? "DA" : "NE") << "\n" ;
}
return 0 ;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
18780 KB |
Output isn't correct |
2 |
Incorrect |
3 ms |
18780 KB |
Output isn't correct |
3 |
Incorrect |
3 ms |
18780 KB |
Output isn't correct |
4 |
Incorrect |
4 ms |
18780 KB |
Output isn't correct |
5 |
Incorrect |
3 ms |
18908 KB |
Output isn't correct |
6 |
Incorrect |
23 ms |
20864 KB |
Output isn't correct |
7 |
Incorrect |
23 ms |
20820 KB |
Output isn't correct |
8 |
Incorrect |
24 ms |
20820 KB |
Output isn't correct |
9 |
Incorrect |
24 ms |
20820 KB |
Output isn't correct |
10 |
Incorrect |
27 ms |
21240 KB |
Output isn't correct |