# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
251426 | Vladikus004 | Programiranje (COCI17_programiranje) | C++14 | 41 ms | 5752 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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";
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |