Submission #622315

# Submission time Handle Problem Language Result Execution time Memory
622315 2022-08-04T07:06:48 Z Trisanu_Das Programiranje (COCI17_programiranje) C++17
80 / 80
235 ms 1876 KB
#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 time Memory Grader output
1 Correct 3 ms 340 KB Output is correct
2 Correct 3 ms 316 KB Output is correct
3 Correct 5 ms 316 KB Output is correct
4 Correct 3 ms 340 KB Output is correct
5 Correct 4 ms 212 KB Output is correct
6 Correct 235 ms 1872 KB Output is correct
7 Correct 223 ms 1876 KB Output is correct
8 Correct 191 ms 1808 KB Output is correct
9 Correct 208 ms 1860 KB Output is correct
10 Correct 183 ms 1764 KB Output is correct