# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
83362 | heon | Programiranje (COCI17_programiranje) | C++11 | 43 ms | 11904 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 pre[26][50005];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
string s;
cin >> s;
int n = s.size();
for(int i = 0; i < n; i++){
if(!i) pre[s[i] - 'a'][i] = 1;
else{
pre[s[i] - 'a'][i]++;
for(int j = 0; j < 26; j++) pre[j][i] += pre[j][i-1];
}
}
int q;
cin >> q;
while(q--){
int a,b,c,d;
cin >> a >> b >> c >> d;
a--,b--,c--,d--;
if(abs(a - b) != abs(c - d)) cout << "NE\n";
else{
bool ok = 1;
for(int j = 0; j < 26; j++){
if(a == 0){
if(pre[j][b] != pre[j][d] - pre[j][c-1]){
ok = 0;
break;
}
}
else{
if(pre[j][b] - pre[j][a-1] != pre[j][d] - pre[j][c-1]){
ok = 0;
break;
}
}
}
cout << (ok ? "DA\n" : "NE\n");
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |