제출 #850223

#제출 시각아이디문제언어결과실행 시간메모리
850223elotelo966Programiranje (COCI17_programiranje)C++17
80 / 80
28 ms27124 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int #define OYY 100000005 #define mod 100000007 #define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define mid (start+end)/2 #define lim 500005 int pre[30][lim]; int32_t main(){ faster string s;cin>>s; // s="+"+s; int n=s.length(); for(int i=0;i<n;i++){ pre[s[i]-'a'][i]++; for(int j=0;j<28;j++){ if(i!=0)pre[j][i]+=pre[j][i-1]; } } //cout<<"j"<<endl; int q;cin>>q; while(q--){ int a,b,c,d; cin>>a>>b>>c>>d; a--;b--;c--;d--; if(b-a!=d-c){ cout<<"NE"<<'\n'; continue; } bool stop=true; for(int i=0;i<28;i++){ int da,dc; if(a-1<0)da=0; else da=pre[i][a-1]; if(c-1<0)dc=0; else dc=pre[i][c-1]; if(pre[i][b]-da!=pre[i][d]-dc){ stop=false; break; } } if(stop){ cout<<"DA"<<'\n'; } else cout<<"NE"<<'\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...