# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
38170 | wasyl | Programiranje (COCI17_programiranje) | C++11 | 369 ms | 7552 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 <vector>
#include <iostream>
#include <algorithm>
#define d(...) __VA_ARGS__
#define all(x) (x).begin(), (x).end()
#define eb(...) emplace_back(__VA_ARGS__)
using namespace std;using ll=long long;
template<class t>using V = vector< t >;
V< V< int > > tab;
V< int > foo (int lo, int hi) {
V< int > res (26);
for (int i = 0; i < 26; ++i)
res[i] = tab[i][hi] - tab[i][lo - 1];
return res;
}
int main()
{
ios::sync_with_stdio(false);
string s; cin >> s;
s = 'a' + s;
tab.resize(26, V< int >(s.size()));
for (int i = 0; i < s.size(); ++i)
++tab[s[i] - 'a'][i];
for (int i = 0; i < 26; ++i)
for (int k = 1; k < s.size(); ++k)
tab[i][k] += tab[i][k - 1];
int q; cin >> q;
while (q--) {
int lo, hi, lo2, hi2;
cin >> lo >> hi >> lo2 >> hi2;
V< int > z = foo(lo, hi);
V< int > z2 = foo(lo2, hi2);
int i = 0;
for (; i < 26; ++i)
if (z[i] != z2[i]) {
cout << "NE\n";
break;
}
if (i == 26)
cout << "DA\n";
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |