# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
942538 | vjudge1 | Programiranje (COCI17_programiranje) | C++17 | 24 ms | 19800 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;
#define ll long long
const int N = 2e5 + 5;
string s;
int cnt[26][N], n, q ;
int32_t main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> s ; n = s.size() ;
s = '#' + s;
for (int i = 1 ; i <= n ; i++) {
cnt[s[i] - 'a'][i] = 1 ;
}
for (int i = 0 ; i < 26 ; i++) {
for (int j = 1 ; j <= n ; j++) {
cnt[i][j] += cnt[i][j - 1] ;
}
}
cin >> q ;
while (q--) {
int a, b, c, d; cin >> a >> b >> c >> d ;
bool ok = 1 ;
for (int i = 0 ; i < 26 ; i++) {
int x = cnt[i][b] - cnt[i][a - 1] ;
int y = cnt[i][d] - cnt[i][c - 1] ;
ok &= (x == y) ;
}
cout << (ok ? "DA" : "NE") << "\n" ;
}
return 0 ;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |