Submission #251426

#TimeUsernameProblemLanguageResultExecution timeMemory
251426Vladikus004Programiranje (COCI17_programiranje)C++14
80 / 80
41 ms5752 KiB
#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 (stderr)

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++){
                     ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...