Submission #879715

# Submission time Handle Problem Language Result Execution time Memory
879715 2023-11-28T01:26:33 Z 1075508020060209tc Programiranje (COCI17_programiranje) C++14
80 / 80
104 ms 13240 KB
//#pragma gcc optimize("O2")
#include <bits/stdc++.h>
//#include<complex>
using namespace std;
#define int long long
int n;
string s;
int ps[29][200005];

signed main(){
cin>>s;
n=s.size();
s="*"+s;
for(int i=1;i<=n;i++){
    for(int c=0;c<=28;c++){
        ps[c][i]=ps[c][i-1];
    }
    ps[s[i]-'a'][i]++;
}
int Q;
cin>>Q;
while(Q--){
    int a;int b;int l;int r;
    cin>>a>>b>>l>>r;
    if(b-a!=r-l){
        cout<<"NE\n";
        continue;
    }
    int ok=1;
    for(int i=0;i<=28;i++){
        if(ps[i][b]-ps[i][a-1]!=ps[i][r]-ps[i][l-1]){
           ok=0;break;
        }
    }
    if(ok){
        cout<<"DA\n";
    }else{
        cout<<"NE\n";
    }
}

}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 860 KB Output is correct
2 Correct 2 ms 860 KB Output is correct
3 Correct 2 ms 860 KB Output is correct
4 Correct 3 ms 856 KB Output is correct
5 Correct 2 ms 860 KB Output is correct
6 Correct 101 ms 13124 KB Output is correct
7 Correct 101 ms 13116 KB Output is correct
8 Correct 103 ms 13240 KB Output is correct
9 Correct 102 ms 13224 KB Output is correct
10 Correct 104 ms 13140 KB Output is correct