답안 #740038

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
740038 2023-05-12T02:10:32 Z mzv Programiranje (COCI17_programiranje) C++17
80 / 80
28 ms 6996 KB
#include <bits/stdc++.h>

#define ccd ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'

using namespace std;

/* ------------------------ hi lol ------------------------ */

// author : mzv

ll n,slen,x1,x2,x3,x4;
string s;
vector<vector<int>>memo(27,vector<int>(50001,0));
bool correct=false;

int main() {
	ccd
	// hitung jumlah huruf a sampai z di rentang 1 sampai n
	// prefix sum
	cin >> s;
	slen=s.length();
	for (int i=1;i<=26;i++) {
		for (int j=1;j<=slen;j++) {
			if (j>1) memo[i][j]=memo[i][j-1];
			if ((s[j-1]-'a'+1)==i) {
				memo[i][j]++; // bnyk huruf ke-i dr rentang 1 sampai j adlh sbnyk memo[i][j]
			}
		}
	}
	// udh selesai hitung, skrng prosesnya
	cin >> n;
	for (int v=1;v<=n;v++) {
		correct=true;
		cin >> x1 >> x2 >> x3 >> x4;
		for (int i=1;i<=26;i++) {
			if ((memo[i][x2]-memo[i][x1-1])!=(memo[i][x4]-memo[i][x3-1])) { // ingat cara yg digunakan ketika lu ngitung jmlh bil. yg habis dibagi direntang x-y dgn x!=1
			//	cout << i << endl;
				correct=false;
				break;
			}
		}
		cout << (correct ? "DA" : "NE") << endl;
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5716 KB Output is correct
2 Correct 4 ms 5716 KB Output is correct
3 Correct 3 ms 5716 KB Output is correct
4 Correct 3 ms 5716 KB Output is correct
5 Correct 3 ms 5716 KB Output is correct
6 Correct 27 ms 6996 KB Output is correct
7 Correct 28 ms 6944 KB Output is correct
8 Correct 26 ms 6916 KB Output is correct
9 Correct 26 ms 6944 KB Output is correct
10 Correct 26 ms 6984 KB Output is correct