Submission #639848

#TimeUsernameProblemLanguageResultExecution timeMemory
639848mannshah1211Programiranje (COCI17_programiranje)C++14
80 / 80
131 ms6776 KiB
#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 timeMemoryGrader output
Fetching results...