답안 #140873

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
140873 2019-08-05T22:58:26 Z Ort Programiranje (COCI17_programiranje) C++11
80 / 80
51 ms 6848 KB
#include<bits/stdc++.h>
#define MEM(a, b) memset(a, (b), sizeof(a))
#define ALL(c) (c).begin(),(c).end()
#define LINF (int)1e18
#define INF (int)1e9
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAX 50005
#define C 30

using namespace std;

string s;
int q, a, b, c, d, n;
int pref[C][MAX];
bool valid;

int main() {
	IO;
	cin >> s; n = s.size();
	for(char cr='a';cr<='z';cr++) {
		for(int i=1;i<=n;i++) if(s[i-1]==cr) pref[int(cr)-97][i]++;
		for(int i=1;i<=n;i++) pref[int(cr)-97][i] += pref[int(cr)-97][i-1];
	}
	cin >> q;
	while(q--) {
		cin >> a >> b >> c >> d; valid = 1;
		for(char cr='a';cr<='z';cr++)
			if((pref[int(cr)-97][b]-pref[int(cr)-97][a-1])!=(pref[int(cr)-97][d]-pref[int(cr)-97][c-1])) valid = 0;
		valid?cout << "DA": cout << "NE"; cout << "\n";	
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 636 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 3 ms 632 KB Output is correct
4 Correct 3 ms 632 KB Output is correct
5 Correct 3 ms 632 KB Output is correct
6 Correct 51 ms 6752 KB Output is correct
7 Correct 49 ms 6776 KB Output is correct
8 Correct 47 ms 6776 KB Output is correct
9 Correct 48 ms 6848 KB Output is correct
10 Correct 48 ms 6776 KB Output is correct