답안 #251426

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
251426 2020-07-21T08:11:25 Z Vladikus004 Programiranje (COCI17_programiranje) C++14
80 / 80
41 ms 5752 KB
#include <bits/stdc++.h>
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

const int N = 50000 + 3;
string s;
int t, a, b, c, d, cnt[N][26], cur[26];

void add(int l, int r, int w){
    for (int i = 0; i < 26; i++)
        cur[i] += w * cnt[r][i];
    if (l)
    for (int i = 0; i < 26; i++)
        cur[i] -= w * cnt[l - 1][i];
}

bool check(){
    for (int i = 0; i < 26; i++)
        if (cur[i]) return false;
    return true;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif // LOCAL
    cin >> s >> t;
    for (int i = 0; i < s.size(); i++){
        cnt[i][s[i] - 'a'] = 1;
        if (i)
        for (int j = 0; j < 26; j++)
            cnt[i][j] += cnt[i - 1][j];
    }
    while (t--){
        cin >> a >> b >> c >> d;
        --a; --b; --c; --d;
        fill(cur, cur + 26, 0);
        add(a, b, 1);
        add(c, d, -1);
        if (check()){
            cout << "DA\n";
        }else{
            cout << "NE\n";
        }
    }
}

Compilation message

programiranje.cpp: In function 'int main()':
programiranje.cpp:35:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < s.size(); i++){
                     ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 38 ms 5752 KB Output is correct
7 Correct 40 ms 5632 KB Output is correct
8 Correct 37 ms 5632 KB Output is correct
9 Correct 36 ms 5632 KB Output is correct
10 Correct 41 ms 5632 KB Output is correct