# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
251426 | Vladikus004 | Programiranje (COCI17_programiranje) | C++14 | 41 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>
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
const int N = 50000 + 3;
string s;
int t, a, b, c, d, cnt[N][26], cur[26];
void add(int l, int r, int w){
for (int i = 0; i < 26; i++)
cur[i] += w * cnt[r][i];
if (l)
for (int i = 0; i < 26; i++)
cur[i] -= w * cnt[l - 1][i];
}
bool check(){
for (int i = 0; i < 26; i++)
if (cur[i]) return false;
return true;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
#ifdef LOCAL
freopen("input.txt", "r", stdin);
#endif // LOCAL
cin >> s >> t;
for (int i = 0; i < s.size(); i++){
cnt[i][s[i] - 'a'] = 1;
if (i)
for (int j = 0; j < 26; j++)
cnt[i][j] += cnt[i - 1][j];
}
while (t--){
cin >> a >> b >> c >> d;
--a; --b; --c; --d;
fill(cur, cur + 26, 0);
add(a, b, 1);
add(c, d, -1);
if (check()){
cout << "DA\n";
}else{
cout << "NE\n";
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |