#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vll vector<long long>
#define pb push_back
using ll= long long;
#define fast_io ios::sync_with_stdio(0); cin.tie(0)
#define inpint(x) int x; cin>>x
#define inpll(x) long long x; cin>>x
#define fl(i, n) for(int i=0; i<n; i++)
#define fl_1(i, n) for(int i=1; i<=n; i++)
#define int long long
#define pi pair<int, int>
#define mp make_pair
#define ld long double
void solve()
{
string s;
cin>>s;
int n = (int)s.size();
s = ' '+s;
int q;
cin>>q;
vector<vector<int>> word(n+1, vector<int>(26, 0));
for(int i=1; i<=n; i++)
{
for(int j=0 ; j<26; j++)
{
word[i][j] = word[i-1][j];
}
char a = s[i];
word[i][a-97]++;
}
while(q--)
{
int a, b, c, d;
cin>>a>>b>>c>>d;
vector<int> x(26, 0);
vector<int> y(26, 0);
for(int i=0; i<26; i++)
{
x[i] = word[b][i] - word[a-1][i];
y[i] = word[d][i] - word[c-1][i];
}
if(x==y) cout<<"DA\n";
else cout<<"NE\n";
}
}
int32_t main()
{
fast_io;
int t=1;
//cin>>t;
while(t--)
{
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
580 KB |
Output is correct |
3 |
Correct |
1 ms |
588 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
40 ms |
13772 KB |
Output is correct |
7 |
Correct |
36 ms |
13692 KB |
Output is correct |
8 |
Correct |
36 ms |
13772 KB |
Output is correct |
9 |
Correct |
37 ms |
13764 KB |
Output is correct |
10 |
Correct |
41 ms |
13748 KB |
Output is correct |