답안 #509212

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
509212 2022-01-14T03:59:00 Z kevinxiehk Programiranje (COCI17_programiranje) C++17
80 / 80
37 ms 11848 KB
#include <bits/stdc++.h>
#define mp make_pair
#define pb emplace_back
#define fi first
#define se second
#define int long long
#define ick cout<<"ickbmi32.9\n"
using namespace std;
bool isprime(int k) {
    for(int i = 2; i <= sqrt(k); i++) if(k % i == 0) return false; 
    return true;    
}
int bm(int a, int b, int mod) {
    if(b == 0) return 1; 
    int t = bm(a, b / 2, mod); 
    t = t * t % mod; 
    return (b % 2 == 1 ? t * a % mod : t);
}
int inv(int a, int mod) {return bm(a, mod - 2, mod);}
int freq[30][50005];
signed main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(0); cout.tie(0);
    string s;
    int q;
    cin >> s;
    cin >> q;
    int n = s.length();
    for(int i = 1; i <= n; i++) {
        freq[s[i - 1] - 'a'][i]++;
    }
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j < 26; j++) freq[j][i] += freq[j][i - 1];
    }
    while(q--) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        bool can = true;
        for(int i = 0; i < 26; i++) {
            if(freq[i][b] - freq[i][a - 1] != freq[i][d] - freq[i][c - 1]) can = false;
        }
        cout << (can ? "DA\n" : "NE\n");
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 588 KB Output is correct
2 Correct 1 ms 588 KB Output is correct
3 Correct 1 ms 592 KB Output is correct
4 Correct 1 ms 588 KB Output is correct
5 Correct 1 ms 588 KB Output is correct
6 Correct 37 ms 11848 KB Output is correct
7 Correct 33 ms 11772 KB Output is correct
8 Correct 30 ms 11804 KB Output is correct
9 Correct 31 ms 11832 KB Output is correct
10 Correct 33 ms 11788 KB Output is correct