Submission #881330

#TimeUsernameProblemLanguageResultExecution timeMemory
881330arashMLGCrossing (JOI21_crossing)C++17
26 / 100
7089 ms5864 KiB
#include<bits/stdc++.h>
#ifdef LOCAL
#include "Essentials/algo/debug.h"
#else
#define debug(...) 69
#endif
using namespace std;

typedef long long     ll;
typedef pair<int,int> pii;

const int N = 2e5 + 23;
const ll inf = 1e18;

#define F           first
#define S           second
#define pb          push_back
#define kill(x)     cout<<x<<endl, exit(0);
#define all(x)      x.begin(),x.end()
#define sz(x)       (int)x.size()
#define lc          (v << 1)
#define rc          ((v<<1) |1)

int n,q;
string a,b,c,beg;
vector<string> strs;

string cross(string one,string two) {
	string ans; ans.resize(n+1);
	for(int i = 0; i <= n ; i++) {
		if(one[i] == two[i]) ans[i] = one[i];
		else{
			if('J' != one[i] && 'J' != two[i]) ans[i] = 'J';
			else if('O' != one[i] && 'O' != two[i]) ans[i] = 'O';
			else ans[i] = 'I';
		}
	}
	return ans;
}

int32_t main() {
    cin.tie(nullptr)->sync_with_stdio(false);
	cin>>n>>a>>b>>c; a= "#" + a; b = "#" + b; c = "#" + c;
	strs.pb(a);
	strs.pb(b);
	strs.pb(c);
	strs.pb(cross(a,b));
	strs.pb(cross(a,c));
	strs.pb(cross(b,c));
	strs.pb(cross(cross(a,b),c));
	strs.pb(cross(cross(a,c),b));
	strs.pb(cross(cross(b,a),c));
	strs.pb(cross(cross(b,c),a));
	strs.pb(cross(cross(c,a),b));
	strs.pb(cross(cross(c,b),a));
	cin>>q>>beg; beg = "#" + beg;
	bool ans = false;
	for(string hello : strs) ans |= (beg == hello);
	cout<<(ans ? "Yes" : "No") << '\n';
	while(q--) {
		int l,r; char c; cin>>l>>r>>c;
		for(int i = l ; i <= r; i ++) beg[i] = c;
		ans = false;
		for(string hello : strs) ans |= (beg == hello);
		cout<<(ans ? "Yes" : "No") << '\n';
	}
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...