Submission #509212

#TimeUsernameProblemLanguageResultExecution timeMemory
509212kevinxiehkProgramiranje (COCI17_programiranje)C++17
80 / 80
37 ms11848 KiB
#include <bits/stdc++.h> #define mp make_pair #define pb emplace_back #define fi first #define se second #define int long long #define ick cout<<"ickbmi32.9\n" using namespace std; bool isprime(int k) { for(int i = 2; i <= sqrt(k); i++) if(k % i == 0) return false; return true; } int bm(int a, int b, int mod) { if(b == 0) return 1; int t = bm(a, b / 2, mod); t = t * t % mod; return (b % 2 == 1 ? t * a % mod : t); } int inv(int a, int mod) {return bm(a, mod - 2, mod);} int freq[30][50005]; signed main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); string s; int q; cin >> s; cin >> q; int n = s.length(); for(int i = 1; i <= n; i++) { freq[s[i - 1] - 'a'][i]++; } for(int i = 1; i <= n; i++) { for(int j = 0; j < 26; j++) freq[j][i] += freq[j][i - 1]; } while(q--) { int a, b, c, d; cin >> a >> b >> c >> d; bool can = true; for(int i = 0; i < 26; i++) { if(freq[i][b] - freq[i][a - 1] != freq[i][d] - freq[i][c - 1]) can = false; } cout << (can ? "DA\n" : "NE\n"); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...