# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1032017 | 7again | Programiranje (COCI17_programiranje) | C++17 | 26 ms | 14380 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 int long long
#define endl "\n"
#define f first
#define s second
#define pb push_back
#define in insert
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define yes cout<<"Yes\n"
#define no cout<<"No\n"
#define FAST ios::sync_with_stdio(0);cout.tie(0);cin.tie(0)
using namespace std ;
void setIO(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
const int N = 60000 , MOD = 1e9+7 ;
//bool inside(int x,int y){return(x<n&&y<m&&x>-1&&y>-1&&a[x][y]!='#');}
//int dx[4]{1 , -1 , 0 , 0} , dy[4]{0 , 0 , 1 , -1} ;
int pfx[27][N] ;
void slv()
{
string s ;
cin >> s ;
int n = s.size() ;
fill_n(&pfx[0][0] , (27) * (N) , 0) ;
for(int i = 1 ; i <= n ; i++)
{
for(char c = 'a' ; c <= 'z' ; c++)
{
if(s[i - 1] == c)
pfx[c - 'a'][i]++ ;
pfx[c - 'a'][i] += pfx[c - 'a'][i - 1] ;
}
}
int q ;
cin >> q ;
while(q--)
{
int l1 , r1 , l2 , r2 , Ok = 1 ;
cin >> l1 >> r1 >> l2 >> r2 ;
l1-- , l2-- ;
for(char c = 'a' ; c <= 'z' ; c++)
{
if(pfx[c - 'a'][r1] - pfx[c - 'a'][l1] != pfx[c - 'a'][r2] - pfx[c - 'a'][l2])
{
cout << "NE" << endl ;
Ok = 0 ;
break ;
}
}
if(Ok)
cout << "DA" << endl ;
}
}
main()
{
//setIO("lasers") ;
FAST ;
int t = 1 ;
//cin >> t ;
while(t--)
slv() ;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |