Submission #83362

#TimeUsernameProblemLanguageResultExecution timeMemory
83362heonProgramiranje (COCI17_programiranje)C++11
80 / 80
43 ms11904 KiB
#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 timeMemoryGrader output
Fetching results...