Submission #624796

# Submission time Handle Problem Language Result Execution time Memory
624796 2022-08-08T18:18:47 Z rm1729 Programiranje (COCI17_programiranje) C++17
80 / 80
134 ms 11892 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

void solve(){
    string a;
    cin >>a;
    vector <vector <int>> pref(26, vector <int> (a.length()+1,0));
    for(int i=1; i<=a.length(); i++){
        for(int j=0; j<26; j++){
            pref[j][i]=pref[j][i-1];
        }    
        int x = (int) a[i-1]-97;
        pref[x][i]++;
    }

    int Q;
    cin >>Q;
    for(int i=0; i<Q; i++){
        int a,b,c,d;
        cin >>a>>b>>c>>d;
        bool flag = false;
        for(int j=0; j<26; j++){
            if(pref[j][b]-pref[j][a-1]!=pref[j][d]-pref[j][c-1]){
                flag = true;
                break;
            }
        }
        if(flag){
                cout <<"NE"<<endl;
            }
        else{
                cout <<"DA"<<endl;
        }
    }
}

signed main(){
    int t=1;// cin >>t;
    while(t--){
        solve();
    }
    return 0;
}

Compilation message

programiranje.cpp: In function 'void solve()':
programiranje.cpp:9:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for(int i=1; i<=a.length(); i++){
      |                  ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 468 KB Output is correct
2 Correct 3 ms 468 KB Output is correct
3 Correct 3 ms 440 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 3 ms 440 KB Output is correct
6 Correct 131 ms 11796 KB Output is correct
7 Correct 134 ms 11884 KB Output is correct
8 Correct 129 ms 11892 KB Output is correct
9 Correct 128 ms 11872 KB Output is correct
10 Correct 133 ms 11868 KB Output is correct