QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#140734#1131. CrossingMohammed_Atalah#0 0ms0kbC++203.2kb2023-08-16 18:26:442024-05-26 00:10:03

Judging History

你现在查看的是最新测评结果

  • [2024-05-26 00:10:03]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2023-08-16 18:26:44]
  • 提交

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') {
			// cout << currO << endl;
			bitset<200000> on;
			bitset<200000> off;
			on = get_ones(l, r);
			off = get_zero(l, r);
			currO = currO | on;
			currJ = currJ & off;
			currI = currI & off;
		} else if (c == 'I') {
			bitset<200000> on;
			bitset<200000> off;
			on = get_ones(l, r);
			off = get_zero(l, r);
			currI = currI | on;
			currJ = currJ & off;
			currO = currO & off;
		} else {
			bitset<200000> on;
			bitset<200000> off;
			on = get_ones(l, r);
			off = get_zero(l, r);
			currJ = currJ | on;
			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();
	}


}

详细

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%