# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
678456 | KK_1729 | Programiranje (COCI17_programiranje) | C++14 | 51 ms | 23220 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;
// Macros
#define int long long
// #define double long long double
#define pb push_back
#define str string
#define vi vector<int>
#define mp make_pair
#define mi map<int, int>
#define umi unordered_map<int, int>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define all(a) a.begin(), a.end()
#define endl "\n"
int mod = 1000000007;
int INF = 1e18;
template<typename T>
void printMap(T a){
cout << "{ ";
for (auto x: a){
cout << x.first << ": " << x.second << " ";
}
cout << "}" << endl;
}
int min_element(vi a){
int m = 10000000000000;
for (auto x: a){
m = min(m, x);
}
return m;
}
void printVector(vi a){
for (auto x: a){
cout << x << " ";
}
cout << endl;
}
int max_element(vi a){
int m = -1e17;
for (auto x: a){
m = max(m, x);
}
return m;
}
int max(int x, int y){
if (x > y) return x;
else return y;
}
int min(int x, int y){
if (x < y) return x;
else return y;
}
void solve(){
string inp; cin >> inp;
int n = inp.size();
vector<int> a(n);
FOR(i,0,inp.size()){
a[i] = inp[i]-'a'+1;
}
int count[27][n];
int prefix[27][n];
FOR(i,0,27){
FOR(j,0,n){
count[i][j] = 0;
}
}
FOR(i,0,n){
count[a[i]][i] = 1;
}
FOR(i,1,27){
prefix[i][0] = count[i][0];
FOR(j,1,n) prefix[i][j] = count[i][j]+prefix[i][j-1];
}
int q; cin >> q;
while (q--){
int l1, r1, l2, r2; cin >> l1 >> r1 >> l2 >> r2;
l1--;r1--;l2--;r2--;
int can = true;
FOR(i,1,27){
int count = prefix[i][r1];
if (l1) count -= prefix[i][l1-1];
int count2 = prefix[i][r2];
if (l2) count2 -= prefix[i][l2-1];
if (count != count2) can = false;
// cout << count << count2 << endl;
}
if (can) cout << "DA" << endl;
else cout << "NE" << endl;
}
}
int32_t main(){
ios::sync_with_stdio(false);cin.tie(0);
// int t; cin >> t;
int t = 1;
for (int tc = 1; tc <= t; tc++){
// cout << "Case #" << tc << ": ";
solve();
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |