Submission #225201

# Submission time Handle Problem Language Result Execution time Memory
225201 2020-04-19T14:23:24 Z ngot23 Programiranje (COCI17_programiranje) C++11
80 / 80
38 ms 7688 KB
#include <bits/stdc++.h>

using namespace std;
const int N=50005;
string s;
int cnt[N][30]; /// cnt[i][j]: so luong ki tu j tu vi tri 1 den vi tri i

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if(fopen(".inp", "r")) freopen(".inp", "r", stdin);
    cin >> s;
    int n=s.size();
    s=' '+s;
    for(int i=1 ; i<=n ; ++i) {
        for(int j=0 ; j<26 ; ++j) {
            cnt[i][j]=cnt[i-1][j] + (s[i]-'a' == j);
        }
    }
    int T; cin >> T;
    while(T--) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        if(b-a != d-c) {
            cout << "NE\n";
            continue;
        }

        bool check=1;
        for(int i=0 ; i<26 ; ++i) {
            if(cnt[b][i]-cnt[a-1][i] != cnt[d][i]-cnt[c-1][i]) {
                check=0;
                break;
            }
        }
        cout << (check ? "DA" : "NE") << '\n';
    }


    return 0;
}

Compilation message

programiranje.cpp: In function 'int main()':
programiranje.cpp:10:35: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     if(fopen(".inp", "r")) freopen(".inp", "r", stdin);
                            ~~~~~~~^~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
6 Correct 34 ms 7544 KB Output is correct
7 Correct 34 ms 7552 KB Output is correct
8 Correct 34 ms 7544 KB Output is correct
9 Correct 38 ms 7672 KB Output is correct
10 Correct 35 ms 7688 KB Output is correct