QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#140735 | #1131. Crossing | Mohammed_Atalah# | 0 | 0ms | 0kb | C++20 | 3.1kb | 2023-08-16 18:29:35 | 2024-05-31 19:05:46 |
answer
/// Template path: /home/mohammed/.config/sublime-text-3/Packages/User
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
// typedef
typedef long long ll;
typedef long double ld;
typedef vector<int> vecint;
typedef vector<char> vecchar;
typedef vector<string> vecstr;
typedef vector<long long> vecll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// Marcos
#define endl ("\n")
#define int long long
#define mod 1000000007
#define pi (3.141592653589)
#define REP(i,a,b) for (int i = a; i < b; i++)
#define RREP(i,a,b) for (int i = a; i > b; i--)
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
// Functions
long long squared(long long x) {return (x * x) % mod;}
int factorial(int n) {long long res = 1; for (int i = 1; i <= n; i++) {res = ((res * i) % mod + mod) % mod ;} return res;}
long long power(long long x, long long p) {if (p == 0) {return 1;} if (p % 2 == 1) {return (power(x, p - 1) * x) % mod;} return squared(power(x, p / 2));}
// cout << fixed;
// cout << setprecision(4);
// ---------(^_^)--------- //
bitset<200000> get_zero(int l, int r) {
bitset<200000> s1;
s1 = ~s1;
s1 = s1 << r;
bitset<200000> s2;
s2 = ~s2;
s2 = s2 >> (200000 - l + 1);
return s2 | s1;
}
bitset<200000> get_ones(int l, int r) {
return ~get_zero(l, r);
}
void main_solve() {
// cout << get_ones(1, 1) << endl;
bitset<200000> J;
bitset<200000> O;
bitset<200000> I;
int n; cin >> n;
string s;
cin >> s >> s >> s;
for (int i = 0; i < n ; i ++) {
if (s[i] == 'J') {
J[i] = 1;
} else if (s[i] == 'O') {
O[i] = 1;
} else {
I[i] = 1;
}
}
bitset<200000> currJ;
bitset<200000> currO;
bitset<200000> currI;
int q; cin >> q;
cin >> s;
for (int i = 0; i < n ; i ++) {
if (s[i] == 'J') {
currJ[i] = 1;
} else if (s[i] == 'O') {
currO[i] = 1;
} else {
currI[i] = 1;
}
}
if (currI == I && currO == O && currJ == J) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
while (q--) {
int l, r; cin >> l >> r;
char c; cin >> c;
// cout << c << endl;
if (c == 'O') {
bitset<200000> off;
off = get_zero(l, r);
currO = currO | get_ones(l, r);
currJ = currJ & off;
currI = currI & off;
} else if (c == 'I') {
bitset<200000> off;
off = get_zero(l, r);
currI = currI | get_ones(l, r);
currJ = currJ & off;
currO = currO & off;
} else {
bitset<200000> off;
off = get_zero(l, r);
currJ = currJ | get_ones(l, r);
currI = currI & off;
currO = currO & off;
}
if (currI == I && currO == O && currJ == J) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
}
int32_t main() {
fast;
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
// #endif
// Just another problem (-_-)
int t;
t = 1;
// cin >> t;
while (t--) {
main_solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Time Limit Exceeded
Test #1:
score: 0
Time Limit Exceeded
input:
80 JJIJOJOJOJIJJIJJIJJIJIIIJIIJIJIJIIIJIJOOIIIJIOIIOJJOOJOJJOJJOOIIOOOOOJIIOIJOJIIJ JJIJOJOJOJIJJIJJIJJIJIIIJIIJIJIJIIIJIJOOIIIJIOIIOJJOOJOJJOJJOOIIOOOOOJIIOIJOJIIJ JJIJOJOJOJIJJIJJIJJIJIIIJIIJIJIJIIIJIJOOIIIJIOIIOJJOOJOJJOJJOOIIOOOOOJIIOIJOJIIJ 185606 IIJJOJIOJOIJIJJJJIOOJIIIIIIJIOIIOJOIJOIJOIJOJOI...
output:
No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No ...
result:
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%