Submission #1192090

#TimeUsernameProblemLanguageResultExecution timeMemory
1192090Kel_MahmutCrossing (JOI21_crossing)C++20
26 / 100
7091 ms6304 KiB
#include<bits/stdc++.h>
#define pb push_back
#define all(aa) aa.begin(), aa.end()
#define endl ("\n")
typedef long long ll;

using namespace std;

int main(){
	int n, q;
	string a, b, c, t;
	cin >> n;
	cin >> a >> b >> c;
	cin >> q;
	cin >> t;
	vector<pair<pair<int, int>, char>> u(q);
	for(int i = 0; i < q; i++){
		cin >> u[i].first.first >> u[i].first.second >> u[i].second;
	}
	auto check = [&](string x, string y){
		bool ok = 1;
		for(int i = 0; i < n; i++) ok &= (x[i] == y[i]);
		return ok;
	};
	auto isl = [&](string x, string y){
		string ret = x;
		for(int i = 0; i < n; i++){
			if(x[i] == y[i]) ret[i] = x[i];
			if(x[i] == 'J' && y[i] == 'O') ret[i] = 'I';
			if(x[i] == 'O' && y[i] == 'J') ret[i] = 'I';

			if(x[i] == 'J' && y[i] == 'I') ret[i] = 'O';
			if(x[i] == 'I' && y[i] == 'J') ret[i] = 'O';

			if(x[i] == 'I' && y[i] == 'O') ret[i] = 'J';
			if(x[i] == 'O' && y[i] == 'I') ret[i] = 'J';
		}
		return ret;
	};
	vector<string> f;
	f.pb(a);
	f.pb(b);
	f.pb(c);
	f.pb(isl(a, b));
	f.pb(isl(a, c));
	f.pb(isl(b, c));
	f.pb(isl(isl(a, b), c));
	f.pb(isl(isl(a, c), b));
	f.pb(isl(isl(b, c), a));
	auto check_full = [&](string x){
		bool ok = 0;
		for(auto s : f){
			ok |= check(s, x);
		}
		return ok;
	};
	cout << (check_full(t) ? "Yes" : "No") << endl;
	for(int i = 0; i < q; i++){
		int ql = u[i].first.first;
		int qr = u[i].first.second;
		char c = u[i].second;
		for(int j = ql - 1; j <= qr - 1; j++) t[j] = c;
		cout << (check_full(t) ? "Yes" : "No") << endl;
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...