# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
115712 | Leonardo_Paes | Programiranje (COCI17_programiranje) | C++11 | 162 ms | 6264 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>
#define MAXN 50010
using namespace std;
int prefix[30][MAXN];
int main()
{
string s;
cin >> s;
for(int i = 0 ; i < s.size() ; i++)
{
prefix[s[i]-97][i+1] = 1;
}
for(int i = 0 ; i < s.size() ; i++)
{
for(int j = 0 ; j < 28 ; j++)
{
if(i != 0) prefix[j][i+1] += prefix[j][i];
// if(j < 2) cout << prefix[j][i+1] << ' ';
}
//cout << endl;
}
int q;
cin >> q;
for(int i = 0 ; i < q ; i++)
{
int a, b, c, d;
cin >> a >> b >> c >> d;
bool ok = true;
if(b-a == d-c)
{
//cout << "hey\n";
for(int i = 0 ; i < 26 ; i++)
{
int k1 = prefix[i][b]-prefix[i][a-1];
int k2 = prefix[i][d]-prefix[i][c-1];
//cout << i << ' ' << k1 << ' ' << k2 << endl;
if(k1 != k2) ok = false;
}
}
else ok = false;
if(ok) cout << "DA\n";
else cout << "NE\n";
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |