| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 750968 | joelgun14 | Crossing (JOI21_crossing) | C++17 | 7096 ms | 2036 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// header file
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// pragma
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
// macros
#define endl "\n"
#define ll long long
#define mp make_pair
#define ins insert
#define lb lower_bound
#define pb push_back
#define ub upper_bound
#define lll __int128
#define fi first
#define se second
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
string operate(string a, string b) {
for(int it = 0; it < a.size(); ++it) {
if(a[it] == b[it])
continue;
bool j = 0, o = 0, i = 0;
if(a[it] == 'J')
j = 1;
else if(a[it] == 'O')
o = 1;
else
i = 1;
if(b[it] == 'J')
j = 1;
else if(b[it] == 'O')
o = 1;
else
i = 1;
if(!j)
a[it] = 'J';
else if(!o)
a[it] = 'O';
else
a[it] = 'I';
}
return a;
}
// buat bit 27 state 1 nya implicit disimpan di segment bawahnya
// remove segment bawahnya per segment gtu
// nanti cnt cari mutually exclusive segment
int cnt[3][3][3][3];
int main() {
ios_base::sync_with_stdio(0); cin.tie(NULL);
int n;
cin >> n;
// coba cek tiap possibility pengambilan
// max pengambilan cmn 3?
string a[3];
cin >> a[0] >> a[1] >> a[2];
int q;
cin >> q;
string init;
cin >> init;
bool ans = 0;
for(int i = 0; i < 3; ++i) {
string tmp = a[i];
for(int j = 0; j < 3; ++j) {
// lakuin operasi antara a[i] dan a[j];
tmp = operate(tmp, a[j]);
for(int k = 0; k < 3; ++k) {
tmp = operate(tmp, a[k]);
if(tmp == init)
ans = 1;
}
}
}
if(ans)
cout << "Yes" << endl;
else
cout << "No" << endl;
// coba permutasi size 1, 2, 3
// given same sequence tp resultnya beda -> pasti gabisa -> O(81Q) -> 1.6e7
// klo misal ga ada yg beda, berarti max ada 27 aja
// klo 27, nanti cek O(27^2*Q) -> 1.4e8
// total O(81Q)
while(q--) {
int l, r;
char x;
cin >> l >> r >> x;
for(int i = l - 1; i <= r - 1; ++i)
init[i] = x;
bool ans = 0;
for(int i = 0; i < 3; ++i) {
string tmp = a[i];
for(int j = 0; j < 3; ++j) {
// lakuin operasi antara a[i] dan a[j];,
tmp = operate(tmp, a[j]);
for(int k = 0; k < 3; ++k) {
tmp = operate(tmp, a[k]);
if(tmp == init)
ans = 1;
}
}
}
if(ans)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
return 0;
}Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
