# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
639848 | mannshah1211 | Programiranje (COCI17_programiranje) | C++14 | 131 ms | 6776 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;
int main(){
string s;
cin >> s;
int n = s.length();
int pre[n][26];
for(int i = 0; i < n; i++){
for(int j = 0; j < 26; j++){
pre[i][j] = 0;
}
}
for(int i = 0; i < n; i++){
for(int j = 0; j < 26; j++){
if(i == 0){
pre[i][j] = (s[0] == ('a' + j));
} else{
pre[i][j] = pre[i - 1][j] + (s[i] == ('a' + j));
}
}
}
int q;
cin >> q;
for(int i = 0; i < q; i++){
int a, b, c, d;
cin >> a >> b >> c >> d;
bool flag = false;
a--, b--, c--, d--;
for(int j = 0; j < 26; j++){
int occ1;
int occ2;
if(a == 0){
occ1 = pre[b][j];
} else{
occ1 = pre[b][j] - pre[a - 1][j];
}
if(c == 0){
occ2 = pre[d][j];
} else{
occ2 = pre[d][j] - pre[c - 1][j];
}
if(occ1 != occ2){
flag = true;
}
}
if(!flag){
puts("DA");
} else{
puts("NE");
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |