# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
115708 | 2019-06-08T17:49:10 Z | luciocf | Programiranje (COCI17_programiranje) | C++14 | 45 ms | 5752 KB |
#include <bits/stdc++.h> using namespace std; const int maxn = 5e4+10; const int maxc = 30; int freq[maxc][maxn]; int main(void) { string s; cin >> s; int n = s.size(); for (int i = 0; i < n; i++) { for (int j = 0; j < 26; j++) freq[j][i+1] = freq[j][i]; freq[(int)s[i]-(int)'a'][i+1] = freq[(int)s[i]-(int)'a'][i]+1; } int q; scanf("%d", &q); for (int i = 1; i <= q; i++) { int a, b, c, d; scanf("%d %d %d %d", &a, &b, &c, &d); if (b-a != d-c) { printf("NE\n"); continue; } bool ok = 1; for (int j = 0; j < 26; j++) if (freq[j][b]-freq[j][a-1] != freq[j][d]-freq[j][c-1]) ok = 0; if (ok) printf("DA\n"); else printf("NE\n"); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 512 KB | Output is correct |
2 | Correct | 3 ms | 512 KB | Output is correct |
3 | Correct | 2 ms | 512 KB | Output is correct |
4 | Correct | 2 ms | 512 KB | Output is correct |
5 | Correct | 3 ms | 512 KB | Output is correct |
6 | Correct | 43 ms | 5604 KB | Output is correct |
7 | Correct | 43 ms | 5632 KB | Output is correct |
8 | Correct | 42 ms | 5752 KB | Output is correct |
9 | Correct | 45 ms | 5752 KB | Output is correct |
10 | Correct | 41 ms | 5604 KB | Output is correct |