# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1100084 |
2024-10-12T16:30:36 Z |
ShaShi |
Crossing (JOI21_crossing) |
C++17 |
|
7000 ms |
18980 KB |
#include <bits/stdc++.h>
#define int long long
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define kill(x) cout << x << "\n", exit(0);
#define pii pair<int, int>
#define pll pair<long long, long long>
#define endl "\n"
using namespace std;
typedef long long ll;
// typedef __int128_t lll;
typedef long double ld;
const int MAXN = (int)1e6 + 7;
const int MOD[] = {(int)1e9 + 11, 998244853};
const int B[] = {34, 9};
const ll INF = (ll)1e9 + 7;
int n, m, k, tmp, t, tmp2, tmp3, tmp4, u, v, w, flag, q, ans, N, X, Y, inv2;
int arr[MAXN], p[2][MAXN];
string Ss[3], T; char ch;
set<pii> st;
inline void check(pii x) {
if (st.find(x) == st.end()) cout << "No\n";
else cout << "Yes\n";
}
inline string cross(string u, string v) {
string res = "";
for (int i=0; i<n; i++) {
if (u[i] == v[i]) res.pb(u[i]);
else if (u[i] != 'I' && v[i] != 'I') res.pb('I');
else if (u[i] != 'O' && v[i] != 'O') res.pb('O');
else res.pb('J');
}
return res;
}
inline int _get_hash(string s, int ind) {
int res = 0;
for (int i=0; i<n; i++) {
if (s[i] == 'J') res = (res*B[ind] + 0)%MOD[ind];
else if (s[i] == 'O') res = (res*B[ind] + 1)%MOD[ind];
else res = (res*B[ind] + 2)%MOD[ind];
}
return res;
}
inline pii get_hash(string s) { return {_get_hash(s, 0), _get_hash(s, 1)}; }
int32_t main() {
#ifdef LOCAL
freopen("inp.in", "r", stdin);
freopen("res.out", "w", stdout);
#else
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#endif
cin >> n;
cin >> Ss[0] >> Ss[1] >> Ss[2];
for (int j=0; j<2; j++) {
p[j][0] = 1;
for (int i=1; i<MAXN; i++) p[j][i] = p[j][i-1]*B[j]%MOD[j];
}
for (int i=0; i<3; i++) {
st.insert(get_hash(Ss[i]));
for (int j=0; j<3; j++) st.insert(get_hash(cross(Ss[i], Ss[j])));
for (int j=0; j<3; j++) for (int k=0; k<3; k++) st.insert(get_hash(cross(cross(Ss[i], Ss[j]), Ss[k])));
}
cin >> q >> T; check(get_hash(T));
while (q--) {
cin >> u >> v >> ch;
for (int i=u-1; i<v; i++) T[i] = ch;
check(get_hash(T));
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
166 ms |
18004 KB |
Output is correct |
2 |
Correct |
210 ms |
18184 KB |
Output is correct |
3 |
Correct |
229 ms |
18000 KB |
Output is correct |
4 |
Correct |
212 ms |
18016 KB |
Output is correct |
5 |
Correct |
190 ms |
18008 KB |
Output is correct |
6 |
Correct |
197 ms |
18004 KB |
Output is correct |
7 |
Correct |
171 ms |
18080 KB |
Output is correct |
8 |
Correct |
230 ms |
18008 KB |
Output is correct |
9 |
Correct |
207 ms |
18004 KB |
Output is correct |
10 |
Correct |
207 ms |
18184 KB |
Output is correct |
11 |
Correct |
208 ms |
18016 KB |
Output is correct |
12 |
Correct |
216 ms |
18140 KB |
Output is correct |
13 |
Correct |
207 ms |
18004 KB |
Output is correct |
14 |
Correct |
212 ms |
18004 KB |
Output is correct |
15 |
Correct |
224 ms |
18084 KB |
Output is correct |
16 |
Correct |
212 ms |
18172 KB |
Output is correct |
17 |
Correct |
212 ms |
18180 KB |
Output is correct |
18 |
Correct |
228 ms |
18004 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
166 ms |
18004 KB |
Output is correct |
2 |
Correct |
210 ms |
18184 KB |
Output is correct |
3 |
Correct |
229 ms |
18000 KB |
Output is correct |
4 |
Correct |
212 ms |
18016 KB |
Output is correct |
5 |
Correct |
190 ms |
18008 KB |
Output is correct |
6 |
Correct |
197 ms |
18004 KB |
Output is correct |
7 |
Correct |
171 ms |
18080 KB |
Output is correct |
8 |
Correct |
230 ms |
18008 KB |
Output is correct |
9 |
Correct |
207 ms |
18004 KB |
Output is correct |
10 |
Correct |
207 ms |
18184 KB |
Output is correct |
11 |
Correct |
208 ms |
18016 KB |
Output is correct |
12 |
Correct |
216 ms |
18140 KB |
Output is correct |
13 |
Correct |
207 ms |
18004 KB |
Output is correct |
14 |
Correct |
212 ms |
18004 KB |
Output is correct |
15 |
Correct |
224 ms |
18084 KB |
Output is correct |
16 |
Correct |
212 ms |
18172 KB |
Output is correct |
17 |
Correct |
212 ms |
18180 KB |
Output is correct |
18 |
Correct |
228 ms |
18004 KB |
Output is correct |
19 |
Execution timed out |
7078 ms |
18980 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
166 ms |
18004 KB |
Output is correct |
2 |
Correct |
210 ms |
18184 KB |
Output is correct |
3 |
Correct |
229 ms |
18000 KB |
Output is correct |
4 |
Correct |
212 ms |
18016 KB |
Output is correct |
5 |
Correct |
190 ms |
18008 KB |
Output is correct |
6 |
Correct |
197 ms |
18004 KB |
Output is correct |
7 |
Correct |
171 ms |
18080 KB |
Output is correct |
8 |
Correct |
230 ms |
18008 KB |
Output is correct |
9 |
Correct |
207 ms |
18004 KB |
Output is correct |
10 |
Correct |
207 ms |
18184 KB |
Output is correct |
11 |
Correct |
208 ms |
18016 KB |
Output is correct |
12 |
Correct |
216 ms |
18140 KB |
Output is correct |
13 |
Correct |
207 ms |
18004 KB |
Output is correct |
14 |
Correct |
212 ms |
18004 KB |
Output is correct |
15 |
Correct |
224 ms |
18084 KB |
Output is correct |
16 |
Correct |
212 ms |
18172 KB |
Output is correct |
17 |
Correct |
212 ms |
18180 KB |
Output is correct |
18 |
Correct |
228 ms |
18004 KB |
Output is correct |
19 |
Correct |
199 ms |
18092 KB |
Output is correct |
20 |
Correct |
222 ms |
17992 KB |
Output is correct |
21 |
Correct |
210 ms |
17996 KB |
Output is correct |
22 |
Correct |
141 ms |
17936 KB |
Output is correct |
23 |
Correct |
211 ms |
17988 KB |
Output is correct |
24 |
Correct |
189 ms |
18004 KB |
Output is correct |
25 |
Correct |
215 ms |
18004 KB |
Output is correct |
26 |
Correct |
161 ms |
18032 KB |
Output is correct |
27 |
Correct |
213 ms |
18004 KB |
Output is correct |
28 |
Correct |
186 ms |
18004 KB |
Output is correct |
29 |
Correct |
211 ms |
18004 KB |
Output is correct |
30 |
Correct |
147 ms |
17848 KB |
Output is correct |
31 |
Correct |
216 ms |
18188 KB |
Output is correct |
32 |
Correct |
201 ms |
18072 KB |
Output is correct |
33 |
Correct |
216 ms |
18016 KB |
Output is correct |
34 |
Correct |
157 ms |
18004 KB |
Output is correct |
35 |
Correct |
214 ms |
18072 KB |
Output is correct |
36 |
Correct |
222 ms |
18004 KB |
Output is correct |
37 |
Correct |
214 ms |
18088 KB |
Output is correct |
38 |
Correct |
209 ms |
18004 KB |
Output is correct |
39 |
Correct |
216 ms |
18128 KB |
Output is correct |
40 |
Correct |
212 ms |
18004 KB |
Output is correct |
41 |
Correct |
209 ms |
18004 KB |
Output is correct |
42 |
Correct |
215 ms |
18004 KB |
Output is correct |
43 |
Correct |
169 ms |
18004 KB |
Output is correct |
44 |
Correct |
219 ms |
18004 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
166 ms |
18004 KB |
Output is correct |
2 |
Correct |
210 ms |
18184 KB |
Output is correct |
3 |
Correct |
229 ms |
18000 KB |
Output is correct |
4 |
Correct |
212 ms |
18016 KB |
Output is correct |
5 |
Correct |
190 ms |
18008 KB |
Output is correct |
6 |
Correct |
197 ms |
18004 KB |
Output is correct |
7 |
Correct |
171 ms |
18080 KB |
Output is correct |
8 |
Correct |
230 ms |
18008 KB |
Output is correct |
9 |
Correct |
207 ms |
18004 KB |
Output is correct |
10 |
Correct |
207 ms |
18184 KB |
Output is correct |
11 |
Correct |
208 ms |
18016 KB |
Output is correct |
12 |
Correct |
216 ms |
18140 KB |
Output is correct |
13 |
Correct |
207 ms |
18004 KB |
Output is correct |
14 |
Correct |
212 ms |
18004 KB |
Output is correct |
15 |
Correct |
224 ms |
18084 KB |
Output is correct |
16 |
Correct |
212 ms |
18172 KB |
Output is correct |
17 |
Correct |
212 ms |
18180 KB |
Output is correct |
18 |
Correct |
228 ms |
18004 KB |
Output is correct |
19 |
Execution timed out |
7078 ms |
18980 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |