#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
string s;
cin >> s;
int q;
cin >> q;
while(q--)
{
int a, b, c, d;
cin >> a >> b >> c >> d;
if(b-a != d-c)
{
cout << "NE\n";
continue;
}
if(a == c && b == d)
{
cout << "DA\n";
continue;
}
if(a >= c && b >= d)
{
swap(a,c);
swap(b,d);
}
//cout << a << " " << b << " " << c << " " << d << '\n';
if(b >= c)
{
int t = b;
b = c-1;
c = t+1;
}
map<char,int> mp;
bool flag = 1;
for(int i = a-1; i < b; ++i)
{
++mp[s[i]];
//cout << s[i] << " " << mp[s[i]] << '\n';
}
for(int i = c-1; i < d; ++i)
{
--mp[s[i]];
//cout << s[i] << " " << mp[s[i]] << '\n';
if(mp[s[i]] < 0)
{
flag = 0;
break;
}
}
//cout << "by flag ";
if(flag)
cout << "DA\n";
else
cout << "NE\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
332 KB |
Output is correct |
2 |
Correct |
11 ms |
340 KB |
Output is correct |
3 |
Correct |
9 ms |
344 KB |
Output is correct |
4 |
Correct |
9 ms |
332 KB |
Output is correct |
5 |
Correct |
8 ms |
340 KB |
Output is correct |
6 |
Execution timed out |
3095 ms |
1548 KB |
Time limit exceeded |
7 |
Execution timed out |
3057 ms |
1664 KB |
Time limit exceeded |
8 |
Execution timed out |
3072 ms |
1744 KB |
Time limit exceeded |
9 |
Execution timed out |
3072 ms |
1568 KB |
Time limit exceeded |
10 |
Execution timed out |
3053 ms |
1592 KB |
Time limit exceeded |