Submission #947474

#TimeUsernameProblemLanguageResultExecution timeMemory
947474vjudge1Programiranje (COCI17_programiranje)C++17
80 / 80
15 ms5976 KiB
#include <bits/stdc++.h> #define fi first #define se second using namespace std; using ll = long long; const int maxN = 5e4 + 1; const int MOD = 1e9 + 7; string s; int n, q, pre[maxN][26]; void ReadInput() { cin >> s; n = s.size(); s = " " + s; } void Solve() { for (int i = 1; i <= n; i++) { pre[i][s[i] - 'a']++; for (int j = 0; j < 26; j++) pre[i][j] += pre[i - 1][j]; } int A, B, C, D; cin >> q; while (q--) { cin >> A >> B >> C >> D; bool flag = true; for (int j = 0; j < 26; j++) if (pre[B][j] - pre[A - 1][j] != pre[D][j] - pre[C - 1][j]) { flag = false; break; } if (flag) cout << "DA\n"; else cout << "NE\n"; } } #define task "" int main() { ios_base::sync_with_stdio(0); cin.tie(0); //freopen(task".INP", "r", stdin); //freopen(task".OUT", "w", stdout); int T = 1; //cin >> T; while (T--) { ReadInput(); Solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...