Submission #1086495

# Submission time Handle Problem Language Result Execution time Memory
1086495 2024-09-10T18:58:25 Z toast12 Programiranje (COCI17_programiranje) C++14
80 / 80
29 ms 7104 KB
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    string s;
    cin >> s;
    vector<vector<int>> ps(26, vector<int>(s.length()+1));
    for (int j = 1; j <= s.length(); j++) {
        for (int i = 0; i < 26; i++) {
            ps[i][j] = ps[i][j-1];
            if (i == s[j-1]-'a')
                ps[i][j]++;
        }
    }
    int q;
    cin >> q;
    while (q--) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        bool ans = true;
        for (int i = 0; i < 26; i++) {
            if (ps[i][b]-ps[i][a-1] != ps[i][d]-ps[i][c-1]) {
                ans = false;
                break;
            }
        }
        if (ans) cout << "DA\n";
        else cout << "NE\n";
    }
    return 0;
}

Compilation message

programiranje.cpp: In function 'int main()':
programiranje.cpp:10:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for (int j = 1; j <= s.length(); j++) {
      |                     ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 29 ms 7104 KB Output is correct
7 Correct 29 ms 6800 KB Output is correct
8 Correct 29 ms 6796 KB Output is correct
9 Correct 29 ms 6796 KB Output is correct
10 Correct 29 ms 6796 KB Output is correct