Submission #654960

# Submission time Handle Problem Language Result Execution time Memory
654960 2022-11-02T08:48:07 Z nifeshe Programiranje (COCI17_programiranje) C++14
80 / 80
33 ms 7248 KB
#include <bits/stdc++.h>

//#pragma GCC target ("avx2")
//#pragma GCC optimize ("O3")
//#pragma GCC optimize ("unroll-loops")
//#pragma comment (linker, "/STACK: 268435456")

#define f first
#define s second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define int unsigned int

using namespace std;

template <typename T> inline bool umin (T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template <typename T> inline bool umax (T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

ll mod = 998244353;
ll base = 1e6 + 9;
int inf = 3e9;
int MAX = 5e4 + 5;

random_device rd;
mt19937 gen(rd());
uniform_int_distribution<ll> dis(1, inf);

void solve() {
    string s;
    cin >> s;
    int n = s.size();
    s = "0" + s;
    vector<vector<int>> pref(n + 1, vector<int>(26));
    for(int i = 1; i <= n; i++) {
        pref[i] = pref[i - 1];
        pref[i][s[i] - 'a']++;
    }
    int q;
    cin >> q;
    while(q--) {
        int l, r, ll, rr;
        cin >> l >> r >> ll >> rr;
        l--, ll--;
        bool flag = 1;
        for(int i = 0; i < 26; i++) {
            flag &= (pref[r][i] - pref[l][i]) == (pref[rr][i] - pref[ll][i]);
        }
        cout << (flag? "DA" : "NE") << '\n';
    }
}

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int ttt = 1;
    //cin >> ttt;
    int ttt0 = ttt;
    while(ttt--) {
        solve();
    }
}

Compilation message

programiranje.cpp: In function 'int main()':
programiranje.cpp:60:9: warning: unused variable 'ttt0' [-Wunused-variable]
   60 |     int ttt0 = ttt;
      |         ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 33 ms 7248 KB Output is correct
7 Correct 23 ms 7108 KB Output is correct
8 Correct 25 ms 7124 KB Output is correct
9 Correct 24 ms 7080 KB Output is correct
10 Correct 28 ms 7140 KB Output is correct