Submission #86099

#TimeUsernameProblemLanguageResultExecution timeMemory
86099MatesV13Programiranje (COCI17_programiranje)C++11
80 / 80
42 ms16792 KiB
#include <bits/stdc++.h>
using namespace std;
long long q, a, b, c, d, e, f, x, ok = 1, slova[26][50000];
string word;
int main (){
ios::sync_with_stdio(0);
cin.tie(0);
	cin >> word;
	for (int i=0;i<word.size();i++){
		for (int j=0;j<26;j++) slova[j][i] = slova[j][i-1];
		slova[int(word[i])-97][i]++;
	}
	cin >> q;
	for(int i=0;i<q;i++){
		cin >> a >> b >> c >> d;
		for (int j=0;j<26;j++){
			if (a==1) e = slova[j][b-1];
			else e = slova[j][b-1] - slova[j][a-2];
			if (c==1) f = slova[j][d-1];
			else f = slova[j][d-1] - slova[j][c-2];
			if (e != f){
				ok = 0;
				break;
			}
		}
		if (ok) cout << "DA\n";
		else cout << "NE\n";
		ok = 1;
	}
return 0;
}

Compilation message (stderr)

programiranje.cpp: In function 'int main()':
programiranje.cpp:9:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=0;i<word.size();i++){
               ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...