Submission #140873

#TimeUsernameProblemLanguageResultExecution timeMemory
140873OrtProgramiranje (COCI17_programiranje)C++11
80 / 80
51 ms6848 KiB
#include<bits/stdc++.h> #define MEM(a, b) memset(a, (b), sizeof(a)) #define ALL(c) (c).begin(),(c).end() #define LINF (int)1e18 #define INF (int)1e9 #define ll long long #define pb push_back #define mp make_pair #define MOD 1000000007 #define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define MAX 50005 #define C 30 using namespace std; string s; int q, a, b, c, d, n; int pref[C][MAX]; bool valid; int main() { IO; cin >> s; n = s.size(); for(char cr='a';cr<='z';cr++) { for(int i=1;i<=n;i++) if(s[i-1]==cr) pref[int(cr)-97][i]++; for(int i=1;i<=n;i++) pref[int(cr)-97][i] += pref[int(cr)-97][i-1]; } cin >> q; while(q--) { cin >> a >> b >> c >> d; valid = 1; for(char cr='a';cr<='z';cr++) if((pref[int(cr)-97][b]-pref[int(cr)-97][a-1])!=(pref[int(cr)-97][d]-pref[int(cr)-97][c-1])) valid = 0; valid?cout << "DA": cout << "NE"; cout << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...