#include<bits/stdc++.h>
using namespace std;
#define int long long
#define in pair<int, int>
#define f first
#define s second
#define pb push_back
#define pob pop_back
#define INF (int)1e17
#define MX (int)3e5+5
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
signed main()
{
fast();
string life;
cin >> life;
int q;
cin >> q;
int n = life.length();
int a[26][n+1];
for(int i = 0; i < 26; i++)
{
a[i][0] = 0;
for(int j = 1; j <= n; j++)
a[i][j] = a[i][j-1]+((life[j-1]-'a')==i);
}
while(q--)
{
int x, y, z, w;
string val = "DA";
cin >> x >> y >> z >> w;
for(int i = 0; i < 26; i++)
{
if(a[i][y]-a[i][x-1] != a[i][w]-a[i][z-1])
val = "NE";
}
cout << val << "\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
2 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
52 ms |
11920 KB |
Output is correct |
7 |
Correct |
45 ms |
11852 KB |
Output is correct |
8 |
Correct |
46 ms |
11772 KB |
Output is correct |
9 |
Correct |
64 ms |
11856 KB |
Output is correct |
10 |
Correct |
47 ms |
11836 KB |
Output is correct |