# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
654998 | _Knyaz_ | Programiranje (COCI17_programiranje) | C++17 | 3099 ms | 976 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;
using ll = long long;
#define int ll
#define all(x) (x).begin(),(x).end()
const int mod = 1e9+7;
const double PI = acos( -1. );
void in(){
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
}
bool get(string x, string y){
sort(x.begin(), x.end());
sort(y.begin(), y.end());
int ans = 0, id = 0;
for(int i = 0; i < x.size() && id < y.size(); i++){
if(x[i]==y[id]) ans++;
else i--; id++;
}
return ans == x.size();
}
void solve(){
//in();
string s; cin >> s;
int q; cin >> q;
while(q--){
string x, y;
int a, b, c, d; cin >> a >> b >> c >> d;
for(int i = a-1; i < b; i++)
x+=s[i];
for(int i = c-1; i < d; i++)
y+=s[i];
cout << (get(y, x)?"DA\n":"NE\n");
}
}
signed main(){
cin.tie(0)->sync_with_stdio(0);
int t; t = 1;
//cin >> t;
while(t--) solve();
}
/*
██╗ ██╗███╗ ██╗██╗ ██╗ █████╗ ███████╗
██║ ██╔╝████╗ ██║╚██╗ ██╔╝██╔══██╗╚══███╔╝
█████╔╝ ██╔██╗ ██║ ╚████╔╝ ███████║ ███╔╝
██╔═██╗ ██║╚██╗██║ ╚██╔╝ ██╔══██║ ███╔╝
███████╗██║ ██╗██║ ╚████║ ██║ ██║ ██║███████╗███████╗
╚══════╝╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |