# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
115712 | 2019-06-08T18:00:26 Z | Leonardo_Paes | Programiranje (COCI17_programiranje) | C++11 | 162 ms | 6264 KB |
#include <bits/stdc++.h> #define MAXN 50010 using namespace std; int prefix[30][MAXN]; int main() { string s; cin >> s; for(int i = 0 ; i < s.size() ; i++) { prefix[s[i]-97][i+1] = 1; } for(int i = 0 ; i < s.size() ; i++) { for(int j = 0 ; j < 28 ; j++) { if(i != 0) prefix[j][i+1] += prefix[j][i]; // if(j < 2) cout << prefix[j][i+1] << ' '; } //cout << endl; } int q; cin >> q; for(int i = 0 ; i < q ; i++) { int a, b, c, d; cin >> a >> b >> c >> d; bool ok = true; if(b-a == d-c) { //cout << "hey\n"; for(int i = 0 ; i < 26 ; i++) { int k1 = prefix[i][b]-prefix[i][a-1]; int k2 = prefix[i][d]-prefix[i][c-1]; //cout << i << ' ' << k1 << ' ' << k2 << endl; if(k1 != k2) ok = false; } } else ok = false; if(ok) cout << "DA\n"; else cout << "NE\n"; } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 512 KB | Output is correct |
2 | Correct | 5 ms | 512 KB | Output is correct |
3 | Correct | 4 ms | 512 KB | Output is correct |
4 | Correct | 4 ms | 512 KB | Output is correct |
5 | Correct | 5 ms | 512 KB | Output is correct |
6 | Correct | 148 ms | 6144 KB | Output is correct |
7 | Correct | 151 ms | 6152 KB | Output is correct |
8 | Correct | 150 ms | 6136 KB | Output is correct |
9 | Correct | 152 ms | 6264 KB | Output is correct |
10 | Correct | 162 ms | 6236 KB | Output is correct |