Submission #89148

# Submission time Handle Problem Language Result Execution time Memory
89148 2018-12-10T15:24:25 Z igzi Programiranje (COCI17_programiranje) C++17
80 / 80
123 ms 12064 KB
#include <bits/stdc++.h>
#define maxN 1100005
 
using namespace std;

string s;
int n,q,a,b,c,d,i,j,x[27][50005];

bool proveri(int a,int b,int c,int d){
for(int i=0;i<27;i++){
    if(x[i][b]-x[i][a-1]!=x[i][d]-x[i][c-1]) return false;
}
return true;
}
 
int main() {
    std::ios_base::sync_with_stdio(false);
    cin>>s;
    n=s.size();
    for(i=0;i<n;i++){
        for(j=0;j<27;j++){
            x[j][i+1]=x[j][i];
        }
        x[s[i]-'a'][i+1]++;
    }
    cin>>q;
    for(i=0;i<q;i++){
        cin>>a>>b>>c>>d;
        if(proveri(a,b,c,d)) cout<<"DA"<<endl;
        else cout<<"NE"<<endl;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 632 KB Output is correct
2 Correct 4 ms 748 KB Output is correct
3 Correct 4 ms 748 KB Output is correct
4 Correct 4 ms 856 KB Output is correct
5 Correct 4 ms 1000 KB Output is correct
6 Correct 119 ms 7420 KB Output is correct
7 Correct 123 ms 8552 KB Output is correct
8 Correct 120 ms 9744 KB Output is correct
9 Correct 115 ms 10856 KB Output is correct
10 Correct 114 ms 12064 KB Output is correct