#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define sh cin.tie(0); cin.sync_with_stdio(0); cout.tie(0);
#define FILE freopen("test.in", "r", stdin);
#define vprint(v) for (int ii = 0; ii < v.size(); ii++){cout << v[ii] << " ";}
#define debugv(v) if (v.size() != 0) {cout << "[ "; for (int __ = 0; __ < (int)(v.size()) - 1; __++){cout << v[__] << ", ";} cout << v[(int)(v.size()) - 1] << " ]" << endl;} else {cout << "[]" << endl;}
#define debug cout << "-----------------------------------------------" << endl;
#define print1(a) cout << "{ " << a << " }" << endl;
#define print2(a, b) cout << "{ " << a << ", " << b << " }" << endl;
#define print3(a, b, c) cout << "{ " << a << ", " << b << ", " << c << " }" << endl;
#define print4(a, b, c, d) cout << "{ " << a << ", " << b << ", " << c << ", " << d << " }" << endl;
using namespace std;
//#define int long long
const int INF = 1e9 + 228;
const int MAXN = 228;
vector<int> p[MAXN];
signed main()
{
#ifdef LOCAL
FILE;
#endif
sh;
string s;
cin >> s;
int n = s.size();
for (int j = 'a'; j <= 'z'; j++) {
p[j].pb(0);
}
for (int i = 0; i < n; i++) {
for (int j = 'a'; j <= 'z'; j++) {
p[j].pb(p[j][i] + (j == s[i]));
}
}
int q;
cin >> q;
for (int _ = 0; _ < q; _++) {
bool kek = 1;
int a, b, c, d;
cin >> a >> b >> c >> d;
a--;
b--;
c--;
d--;
for (int j = 'a'; j <= 'z'; j++) {
if (p[j][b + 1] - p[j][a] != p[j][d + 1] - p[j][c]) {
kek = 0;
}
}
if (kek) {
cout << "DA\n";
} else {
cout << "NE\n";
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
504 KB |
Output is correct |
2 |
Correct |
3 ms |
504 KB |
Output is correct |
3 |
Correct |
3 ms |
504 KB |
Output is correct |
4 |
Correct |
3 ms |
504 KB |
Output is correct |
5 |
Correct |
3 ms |
504 KB |
Output is correct |
6 |
Correct |
61 ms |
7556 KB |
Output is correct |
7 |
Correct |
69 ms |
7428 KB |
Output is correct |
8 |
Correct |
57 ms |
7540 KB |
Output is correct |
9 |
Correct |
56 ms |
7552 KB |
Output is correct |
10 |
Correct |
58 ms |
7556 KB |
Output is correct |