Submission #622405

#TimeUsernameProblemLanguageResultExecution timeMemory
622405kabikaProgramiranje (COCI17_programiranje)C++14
40 / 80
3095 ms1744 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); string s; cin >> s; int q; cin >> q; while(q--) { int a, b, c, d; cin >> a >> b >> c >> d; if(b-a != d-c) { cout << "NE\n"; continue; } if(a == c && b == d) { cout << "DA\n"; continue; } if(a >= c && b >= d) { swap(a,c); swap(b,d); } //cout << a << " " << b << " " << c << " " << d << '\n'; if(b >= c) { int t = b; b = c-1; c = t+1; } map<char,int> mp; bool flag = 1; for(int i = a-1; i < b; ++i) { ++mp[s[i]]; //cout << s[i] << " " << mp[s[i]] << '\n'; } for(int i = c-1; i < d; ++i) { --mp[s[i]]; //cout << s[i] << " " << mp[s[i]] << '\n'; if(mp[s[i]] < 0) { flag = 0; break; } } //cout << "by flag "; if(flag) cout << "DA\n"; else cout << "NE\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...