이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// 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;
}
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];
if(tmp == init)
ans = 1;
for(int j = 0; j < 3; ++j) {
if(i == j)
continue;
// lakuin operasi antara a[i] dan a[j];
tmp = operate(tmp, a[j]);
if(tmp == init)
ans = 1;
for(int k = 0; k < 3; ++k) {
if(i == k || j == k)
continue;
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
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];
if(tmp == init)
ans = 1;
for(int j = 0; j < 3; ++j) {
// lakuin operasi antara a[i] dan a[j];
if(i == j)
continue;
tmp = operate(tmp, a[j]);
if(tmp == init)
ans = 1;
for(int k = 0; k < 3; ++k) {
if(i == k || j == k)
continue;
tmp = operate(tmp, a[k]);
if(tmp == init)
ans = 1;
}
}
}
if(ans)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'std::string operate(std::string, std::string)':
Main.cpp:24:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
24 | for(int it = 0; it < a.size(); ++it) {
| ~~~^~~~~~~~~~
Main.cpp:27:28: warning: variable 'i' set but not used [-Wunused-but-set-variable]
27 | bool j = 0, o = 0, i = 0;
| ^
# | 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... |