# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
622315 | Trisanu_Das | Programiranje (COCI17_programiranje) | C++17 | 235 ms | 1876 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
signed main() {
string s; cin >> s;
int n = s.size();
vector<vector<int>> f(26);
for(int i = 0; i < n; i++)
f[s[i] - 'a'].push_back(i);
auto cnt = [&] (int i, int j, int c) {
return upper_bound(f[c].begin(), f[c].end(), j)
- upper_bound(f[c].begin(), f[c].end(), i - 1);
};
int q; cin >> q;
while(q--) {
int a, b, c, d;
cin >> a >> b >> c >> d;
a--, b--, c--, d--;
bool okay = true;
for(int i = 0; i < 26 && okay; i++)
if(cnt(a, b, i) != cnt(c, d, i))
okay = false;
cout << (okay ? "DA" : "NE") << '\n';
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |