Submission #942536

#TimeUsernameProblemLanguageResultExecution timeMemory
942536skywwlaProgramiranje (COCI17_programiranje)C++17
0 / 80
27 ms21240 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int N = 2e5 + 5; string s; int cnt[26][N], n, q ; int32_t main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> s ; n = s.size() ; s = '#' + s; for (int i = 1 ; i <= n ; i++) { cnt[s[i] - 'a'][i] = 1 ; } for (int i = 0 ; i < 26 ; i++) { for (int j = 1 ; j <= n ; j++) { cnt[i][j] += cnt[i][j - 1] ; } } cin >> q ; while (q--) { int a, b, c, d; cin >> a >> b >> c >> d ; bool ok = 1 ; for (int i = 0 ; i < 26 ; i++) { bool x = cnt[i][b] - cnt[i][a - 1] ; bool y = cnt[i][d] - cnt[i][c - 1] ; ok &= (x == y) ; } cout << (ok ? "DA" : "NE") << "\n" ; } return 0 ; }
#Verdict Execution timeMemoryGrader output
Fetching results...