# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
625944 | elesis | Programiranje (COCI17_programiranje) | C++14 | 33 ms | 11644 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);
#define int long long
#define pii pair<int,int>
#define ff first
#define ss second
const int inf=1e11+7;
const int N=107;
const int mod =1000000007;
vector <int> adj[N];
void solve()
{
string s;
cin>>s;
vector <vector <int>> pref(26,vector <int> (s.size()+1,0));
//cout << pref[1][0] << '\n';
int n=s.size();
for(int i=0;i<26;i++)
{
for(int j=1;j<=n;j++)
{
pref[i][j]=pref[i][j-1];
if((s[j-1]-97)==i)
{
pref[i][j]++;
}
}
}
//cout << pref[1][5] << "\n";
int q;
cin>>q;
while(q--)
{
int a,b,c,d;
cin>>a>>b>>c>>d;
bool flag=true;
for(int i=0;i<26;i++)
{
if((pref[i][b]-pref[i][a-1])!=pref[i][d]-pref[i][c-1])
{
//cout << a << " " << b << " " << c << " " << d << '\n';
flag=false;
break;
}
}
if(flag)
{
cout << "DA" << '\n';
}
else
{
cout << "NE" << "\n";
}
}
}
signed main()
{
fast
clock_t start, end;
start = clock();
solve();
end = clock();
double time_taken=double(end-start)/double(CLOCKS_PER_SEC);
//cout << "time taken" << " " << time_taken << "\n";
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |