답안 #942538

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
942538 2024-03-10T20:23:18 Z vjudge1 Programiranje (COCI17_programiranje) C++17
80 / 80
24 ms 19800 KB
#include <bits/stdc++.h>
using namespace std; 
 
#define ll long long

const int N = 2e5 + 5;

string s;
int cnt[26][N], n, q ;

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> s ; n = s.size() ;
    s = '#' + s;
    for (int i = 1 ; i <= n ; i++) {
        cnt[s[i] - 'a'][i] = 1 ;
    }
    for (int i = 0 ; i < 26 ; i++) {
        for (int j = 1 ; j <= n ; j++) {
            cnt[i][j] += cnt[i][j - 1] ;
        }
    }
    cin >> q ;
    while (q--) {
        int a, b, c, d; cin >> a >> b >> c >> d ;
        bool ok = 1 ;
        for (int i = 0 ; i < 26 ; i++) {
            int x = cnt[i][b] - cnt[i][a - 1] ;
            int y = cnt[i][d] - cnt[i][c - 1] ;
            ok &= (x == y) ;
        }
        cout << (ok ? "DA" : "NE") << "\n" ;
    }
    return 0 ;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 18776 KB Output is correct
2 Correct 3 ms 18780 KB Output is correct
3 Correct 3 ms 18780 KB Output is correct
4 Correct 3 ms 18780 KB Output is correct
5 Correct 3 ms 18780 KB Output is correct
6 Correct 22 ms 19644 KB Output is correct
7 Correct 22 ms 19800 KB Output is correct
8 Correct 22 ms 19548 KB Output is correct
9 Correct 24 ms 19548 KB Output is correct
10 Correct 24 ms 19692 KB Output is correct