# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
115708 | luciocf | Programiranje (COCI17_programiranje) | C++14 | 45 ms | 5752 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |