Submission #883010

# Submission time Handle Problem Language Result Execution time Memory
883010 2023-12-04T11:56:27 Z 8pete8 Crossing (JOI21_crossing) C++14
100 / 100
359 ms 27832 KB
#include<iostream>
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<unordered_map>
#include <queue>
#include<cstring>
#include<limits.h>
#include<cmath>
#include<set>
#include<algorithm>
#include <iomanip>
#include<numeric>
#include<bitset>
using namespace std;
#define ll long long
#define f first
#define endl "\n"
//#define s second
#define pii pair<int,int>
#define ppii pair<int,pii>
#define vi vector<int>
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define F(n) for(int i=0;i<n;i++)
#define lb lower_bound
#define ub upper_bound
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
#pragma GCC optimize ("03,unroll-loops")
using namespace std;
#define int long long
const int mod=1e9+7,mxn=2e5+5,lg=30,inf=1e18,minf=-1e18,base=101;
int p[mxn+10],n;
char g[4]={'l','J','O','I'};
int hashchar(char a){
	if(a=='J')return 1;
	else if(a=='O')return 2;
	return 3;
}
int getpow(int l,int r){return l==0?p[r]:(p[r]-p[l-1]+mod)%mod;}
int hashstring(string a){
	int ans=0;
	for(int i=0;i<a.size();i++)ans=(ans+(getpow(i,i)*hashchar(a[i])))%mod;
	return ans;
}
string comb(string a,string b){
	string ans="";
	for(int i=0;i<n;i++){
		if(a[i]==b[i])ans+=a[i];
		else ans+=g[6-(hashchar(a[i])+hashchar(b[i]))];
	}
	return ans;
}
string in;
struct seg{
	int v[4*mxn+10],add[4*mxn+10];
	void push(int l,int r,int node){
		if(add[node]==0)return;
		v[node]=(getpow(l,r)*add[node])%mod;
		if(l!=r)add[node<<1]=add[(node<<1)^1]=add[node];
		add[node]=0;
	}
	void build(int l,int r,int node){
		if(l==r){
			v[node]=(hashchar(in[l])*getpow(l,l))%mod;
			return;
		}
		int mid=l+(r-l)/2;
		build(l,mid,node<<1);
		build(mid+1,r,(node<<1)^1);
		v[node]=(v[node<<1]+v[(node<<1)^1])%mod;
	}
	void update(int l,int r,int ql,int qr,int node,int val){
		push(l,r,node);
		if(l>qr||r<ql)return;
		if(l>=ql&&r<=qr){
			add[node]=val;
			push(l,r,node);
			return;
		}
		int mid=l+(r-l)/2;
		update(l,mid,ql,qr,node<<1,val);
		update(mid+1,r,ql,qr,(node<<1)^1,val);
		v[node]=(v[node<<1]+v[(node<<1)^1])%mod;
	}
}t;
map<int,bool>mp;
int32_t main(){
	fastio
	cin>>n;
	p[0]=1;
	for(int i=1;i<=n;i++)p[i]=(((p[i-1]*base)%mod)+p[i-1])%mod;
	string s[3];
	for(int i=0;i<3;i++)cin>>s[i];
	for(int i=0;i<3;i++){
		mp[hashstring(s[i])]=true;
		for(int j=0;j<3;j++){
			if(i==j)continue;
			if(i<j){
				string tmp=(comb(s[i],s[j]));
				mp[hashstring(tmp)]=true;
				tmp=comb(s[3-(i+j)],tmp);
				mp[hashstring(tmp)]=true;
			}
		}
	}
	int q;cin>>q;
	cin>>in;
	t.build(0,n-1,1);
	if(mp[t.v[1]])cout<<"Yes\n";
	else cout<<"No\n";
	while(q--){
		int l,r;
		cin>>l>>r;
		char L;cin>>L;
		l--,r--;
		t.update(0,n-1,l,r,1,hashchar(L));
		if(mp[t.v[1]])cout<<"Yes\n";
		else cout<<"No\n";
	}
	return 0;
}

Compilation message

Main.cpp: In function 'long long int hashstring(std::string)':
Main.cpp:45:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |  for(int i=0;i<a.size();i++)ans=(ans+(getpow(i,i)*hashchar(a[i])))%mod;
      |              ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 108 ms 11628 KB Output is correct
2 Correct 135 ms 12588 KB Output is correct
3 Correct 89 ms 6112 KB Output is correct
4 Correct 114 ms 12624 KB Output is correct
5 Correct 127 ms 12688 KB Output is correct
6 Correct 106 ms 11900 KB Output is correct
7 Correct 106 ms 12028 KB Output is correct
8 Correct 115 ms 12836 KB Output is correct
9 Correct 127 ms 12712 KB Output is correct
10 Correct 118 ms 14016 KB Output is correct
11 Correct 123 ms 13392 KB Output is correct
12 Correct 139 ms 14160 KB Output is correct
13 Correct 121 ms 13232 KB Output is correct
14 Correct 130 ms 14084 KB Output is correct
15 Correct 116 ms 13396 KB Output is correct
16 Correct 126 ms 14064 KB Output is correct
17 Correct 116 ms 13296 KB Output is correct
18 Correct 74 ms 4296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 108 ms 11628 KB Output is correct
2 Correct 135 ms 12588 KB Output is correct
3 Correct 89 ms 6112 KB Output is correct
4 Correct 114 ms 12624 KB Output is correct
5 Correct 127 ms 12688 KB Output is correct
6 Correct 106 ms 11900 KB Output is correct
7 Correct 106 ms 12028 KB Output is correct
8 Correct 115 ms 12836 KB Output is correct
9 Correct 127 ms 12712 KB Output is correct
10 Correct 118 ms 14016 KB Output is correct
11 Correct 123 ms 13392 KB Output is correct
12 Correct 139 ms 14160 KB Output is correct
13 Correct 121 ms 13232 KB Output is correct
14 Correct 130 ms 14084 KB Output is correct
15 Correct 116 ms 13396 KB Output is correct
16 Correct 126 ms 14064 KB Output is correct
17 Correct 116 ms 13296 KB Output is correct
18 Correct 74 ms 4296 KB Output is correct
19 Correct 359 ms 25212 KB Output is correct
20 Correct 258 ms 22660 KB Output is correct
21 Correct 237 ms 26576 KB Output is correct
22 Correct 209 ms 24100 KB Output is correct
23 Correct 167 ms 20068 KB Output is correct
24 Correct 156 ms 19008 KB Output is correct
25 Correct 239 ms 27580 KB Output is correct
26 Correct 222 ms 25536 KB Output is correct
27 Correct 250 ms 27832 KB Output is correct
28 Correct 258 ms 25580 KB Output is correct
29 Correct 250 ms 27464 KB Output is correct
30 Correct 184 ms 20052 KB Output is correct
31 Correct 347 ms 27800 KB Output is correct
32 Correct 249 ms 25072 KB Output is correct
33 Correct 173 ms 18808 KB Output is correct
34 Correct 239 ms 25668 KB Output is correct
35 Correct 199 ms 24748 KB Output is correct
36 Correct 151 ms 18960 KB Output is correct
37 Correct 152 ms 19028 KB Output is correct
38 Correct 221 ms 19644 KB Output is correct
39 Correct 150 ms 19728 KB Output is correct
40 Correct 189 ms 20648 KB Output is correct
41 Correct 194 ms 16060 KB Output is correct
42 Correct 44 ms 10944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 108 ms 11628 KB Output is correct
2 Correct 135 ms 12588 KB Output is correct
3 Correct 89 ms 6112 KB Output is correct
4 Correct 114 ms 12624 KB Output is correct
5 Correct 127 ms 12688 KB Output is correct
6 Correct 106 ms 11900 KB Output is correct
7 Correct 106 ms 12028 KB Output is correct
8 Correct 115 ms 12836 KB Output is correct
9 Correct 127 ms 12712 KB Output is correct
10 Correct 118 ms 14016 KB Output is correct
11 Correct 123 ms 13392 KB Output is correct
12 Correct 139 ms 14160 KB Output is correct
13 Correct 121 ms 13232 KB Output is correct
14 Correct 130 ms 14084 KB Output is correct
15 Correct 116 ms 13396 KB Output is correct
16 Correct 126 ms 14064 KB Output is correct
17 Correct 116 ms 13296 KB Output is correct
18 Correct 74 ms 4296 KB Output is correct
19 Correct 116 ms 11972 KB Output is correct
20 Correct 95 ms 6148 KB Output is correct
21 Correct 118 ms 13396 KB Output is correct
22 Correct 114 ms 11604 KB Output is correct
23 Correct 119 ms 13476 KB Output is correct
24 Correct 106 ms 12260 KB Output is correct
25 Correct 128 ms 13464 KB Output is correct
26 Correct 100 ms 11980 KB Output is correct
27 Correct 115 ms 13580 KB Output is correct
28 Correct 102 ms 12116 KB Output is correct
29 Correct 127 ms 12888 KB Output is correct
30 Correct 96 ms 11604 KB Output is correct
31 Correct 117 ms 13652 KB Output is correct
32 Correct 121 ms 13532 KB Output is correct
33 Correct 131 ms 13228 KB Output is correct
34 Correct 105 ms 12100 KB Output is correct
35 Correct 119 ms 14088 KB Output is correct
36 Correct 123 ms 13264 KB Output is correct
37 Correct 138 ms 14160 KB Output is correct
38 Correct 112 ms 13396 KB Output is correct
39 Correct 121 ms 14088 KB Output is correct
40 Correct 118 ms 13252 KB Output is correct
41 Correct 123 ms 14020 KB Output is correct
42 Correct 116 ms 13212 KB Output is correct
43 Correct 117 ms 12568 KB Output is correct
44 Correct 112 ms 12884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 108 ms 11628 KB Output is correct
2 Correct 135 ms 12588 KB Output is correct
3 Correct 89 ms 6112 KB Output is correct
4 Correct 114 ms 12624 KB Output is correct
5 Correct 127 ms 12688 KB Output is correct
6 Correct 106 ms 11900 KB Output is correct
7 Correct 106 ms 12028 KB Output is correct
8 Correct 115 ms 12836 KB Output is correct
9 Correct 127 ms 12712 KB Output is correct
10 Correct 118 ms 14016 KB Output is correct
11 Correct 123 ms 13392 KB Output is correct
12 Correct 139 ms 14160 KB Output is correct
13 Correct 121 ms 13232 KB Output is correct
14 Correct 130 ms 14084 KB Output is correct
15 Correct 116 ms 13396 KB Output is correct
16 Correct 126 ms 14064 KB Output is correct
17 Correct 116 ms 13296 KB Output is correct
18 Correct 74 ms 4296 KB Output is correct
19 Correct 359 ms 25212 KB Output is correct
20 Correct 258 ms 22660 KB Output is correct
21 Correct 237 ms 26576 KB Output is correct
22 Correct 209 ms 24100 KB Output is correct
23 Correct 167 ms 20068 KB Output is correct
24 Correct 156 ms 19008 KB Output is correct
25 Correct 239 ms 27580 KB Output is correct
26 Correct 222 ms 25536 KB Output is correct
27 Correct 250 ms 27832 KB Output is correct
28 Correct 258 ms 25580 KB Output is correct
29 Correct 250 ms 27464 KB Output is correct
30 Correct 184 ms 20052 KB Output is correct
31 Correct 347 ms 27800 KB Output is correct
32 Correct 249 ms 25072 KB Output is correct
33 Correct 173 ms 18808 KB Output is correct
34 Correct 239 ms 25668 KB Output is correct
35 Correct 199 ms 24748 KB Output is correct
36 Correct 151 ms 18960 KB Output is correct
37 Correct 152 ms 19028 KB Output is correct
38 Correct 221 ms 19644 KB Output is correct
39 Correct 150 ms 19728 KB Output is correct
40 Correct 189 ms 20648 KB Output is correct
41 Correct 194 ms 16060 KB Output is correct
42 Correct 44 ms 10944 KB Output is correct
43 Correct 116 ms 11972 KB Output is correct
44 Correct 95 ms 6148 KB Output is correct
45 Correct 118 ms 13396 KB Output is correct
46 Correct 114 ms 11604 KB Output is correct
47 Correct 119 ms 13476 KB Output is correct
48 Correct 106 ms 12260 KB Output is correct
49 Correct 128 ms 13464 KB Output is correct
50 Correct 100 ms 11980 KB Output is correct
51 Correct 115 ms 13580 KB Output is correct
52 Correct 102 ms 12116 KB Output is correct
53 Correct 127 ms 12888 KB Output is correct
54 Correct 96 ms 11604 KB Output is correct
55 Correct 117 ms 13652 KB Output is correct
56 Correct 121 ms 13532 KB Output is correct
57 Correct 131 ms 13228 KB Output is correct
58 Correct 105 ms 12100 KB Output is correct
59 Correct 119 ms 14088 KB Output is correct
60 Correct 123 ms 13264 KB Output is correct
61 Correct 138 ms 14160 KB Output is correct
62 Correct 112 ms 13396 KB Output is correct
63 Correct 121 ms 14088 KB Output is correct
64 Correct 118 ms 13252 KB Output is correct
65 Correct 123 ms 14020 KB Output is correct
66 Correct 116 ms 13212 KB Output is correct
67 Correct 117 ms 12568 KB Output is correct
68 Correct 112 ms 12884 KB Output is correct
69 Correct 249 ms 23488 KB Output is correct
70 Correct 311 ms 22572 KB Output is correct
71 Correct 164 ms 18848 KB Output is correct
72 Correct 178 ms 19000 KB Output is correct
73 Correct 164 ms 19004 KB Output is correct
74 Correct 239 ms 25456 KB Output is correct
75 Correct 218 ms 20252 KB Output is correct
76 Correct 237 ms 27412 KB Output is correct
77 Correct 257 ms 24156 KB Output is correct
78 Correct 159 ms 18892 KB Output is correct
79 Correct 168 ms 19092 KB Output is correct
80 Correct 242 ms 24624 KB Output is correct
81 Correct 172 ms 20148 KB Output is correct
82 Correct 252 ms 27432 KB Output is correct
83 Correct 237 ms 24692 KB Output is correct
84 Correct 156 ms 19028 KB Output is correct
85 Correct 156 ms 19024 KB Output is correct
86 Correct 239 ms 23868 KB Output is correct
87 Correct 247 ms 25616 KB Output is correct
88 Correct 174 ms 18272 KB Output is correct
89 Correct 223 ms 24496 KB Output is correct
90 Correct 288 ms 25772 KB Output is correct
91 Correct 161 ms 18300 KB Output is correct
92 Correct 232 ms 24816 KB Output is correct
93 Correct 175 ms 18896 KB Output is correct
94 Correct 168 ms 19028 KB Output is correct
95 Correct 159 ms 19048 KB Output is correct
96 Correct 209 ms 23012 KB Output is correct
97 Correct 152 ms 21012 KB Output is correct
98 Correct 196 ms 20656 KB Output is correct
99 Correct 213 ms 16044 KB Output is correct
100 Correct 54 ms 11060 KB Output is correct