#include <vector>
#include <iostream>
#include <algorithm>
#define d(...) __VA_ARGS__
#define all(x) (x).begin(), (x).end()
#define eb(...) emplace_back(__VA_ARGS__)
using namespace std;using ll=long long;
template<class t>using V = vector< t >;
V< V< int > > tab;
V< int > foo (int lo, int hi) {
V< int > res (26);
for (int i = 0; i < 26; ++i)
res[i] = tab[i][hi] - tab[i][lo - 1];
return res;
}
int main()
{
ios::sync_with_stdio(false);
string s; cin >> s;
s = 'a' + s;
tab.resize(26, V< int >(s.size()));
for (int i = 0; i < s.size(); ++i)
++tab[s[i] - 'a'][i];
for (int i = 0; i < 26; ++i)
for (int k = 1; k < s.size(); ++k)
tab[i][k] += tab[i][k - 1];
int q; cin >> q;
while (q--) {
int lo, hi, lo2, hi2;
cin >> lo >> hi >> lo2 >> hi2;
V< int > z = foo(lo, hi);
V< int > z2 = foo(lo2, hi2);
int i = 0;
for (; i < 26; ++i)
if (z[i] != z2[i]) {
cout << "NE\n";
break;
}
if (i == 26)
cout << "DA\n";
}
}
Compilation message
programiranje.cpp: In function 'int main()':
programiranje.cpp:26:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < s.size(); ++i)
^
programiranje.cpp:29:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int k = 1; k < s.size(); ++k)
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
2312 KB |
Output is correct |
2 |
Correct |
6 ms |
2312 KB |
Output is correct |
3 |
Correct |
6 ms |
2312 KB |
Output is correct |
4 |
Correct |
0 ms |
2312 KB |
Output is correct |
5 |
Correct |
0 ms |
2312 KB |
Output is correct |
6 |
Correct |
253 ms |
7552 KB |
Output is correct |
7 |
Correct |
206 ms |
7552 KB |
Output is correct |
8 |
Correct |
226 ms |
7552 KB |
Output is correct |
9 |
Correct |
236 ms |
7552 KB |
Output is correct |
10 |
Correct |
369 ms |
7552 KB |
Output is correct |