Submission #622315

#TimeUsernameProblemLanguageResultExecution timeMemory
622315Trisanu_DasProgramiranje (COCI17_programiranje)C++17
80 / 80
235 ms1876 KiB
#include <bits/stdc++.h>
using namespace std;

signed main() {
    string s; cin >> s;
    int n = s.size();
    vector<vector<int>> f(26);
    for(int i = 0; i < n; i++)
    	f[s[i] - 'a'].push_back(i);
    auto cnt = [&] (int i, int j, int c) {
    	return upper_bound(f[c].begin(), f[c].end(), j) 
    			- upper_bound(f[c].begin(), f[c].end(), i - 1);
    };
    int q; cin >> q;
    while(q--) {
    	int a, b, c, d;
    	cin >> a >> b >> c >> d;
    	a--, b--, c--, d--;
    	bool okay = true;
    	for(int i = 0; i < 26 && okay; i++)
    		if(cnt(a, b, i) != cnt(c, d, i))
    			okay = false;
    	cout << (okay ? "DA" : "NE") << '\n';
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...