답안 #639848

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
639848 2022-09-12T10:07:34 Z mannshah1211 Programiranje (COCI17_programiranje) C++14
80 / 80
131 ms 6776 KB
#include <bits/stdc++.h>
using namespace std;

int main(){
  string s;
  cin >> s;
  
  int n = s.length();
  int pre[n][26];
  for(int i = 0; i < n; i++){
    for(int j = 0; j < 26; j++){
      pre[i][j] = 0;
    }
  }
  for(int i = 0; i < n; i++){
    for(int j = 0; j < 26; j++){
       if(i == 0){
         pre[i][j] = (s[0] == ('a' + j));
       } else{
         pre[i][j] = pre[i - 1][j] + (s[i] == ('a' + j));
       }
    }
  }
  
  int q;
  cin >> q;
  
  for(int i = 0; i < q; i++){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    bool flag = false;
    a--, b--, c--, d--;
    for(int j = 0; j < 26; j++){
      int occ1;
      int occ2;
      if(a == 0){
        occ1 = pre[b][j];
      } else{
        occ1 = pre[b][j] - pre[a - 1][j];
      }
      
      if(c == 0){
        occ2 = pre[d][j];
      } else{
        occ2 = pre[d][j] - pre[c - 1][j];
      }
      
      if(occ1 != occ2){
        flag = true;
      }
    }
    
    if(!flag){
      puts("DA");
    } else{
      puts("NE");
    }
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 3 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 3 ms 340 KB Output is correct
5 Correct 3 ms 340 KB Output is correct
6 Correct 123 ms 6632 KB Output is correct
7 Correct 131 ms 6776 KB Output is correct
8 Correct 113 ms 6744 KB Output is correct
9 Correct 116 ms 6748 KB Output is correct
10 Correct 113 ms 6736 KB Output is correct