답안 #891317

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
891317 2023-12-22T18:18:57 Z iris2617 Crossing (JOI21_crossing) C++14
100 / 100
1933 ms 215948 KB
#include<bits/stdc++.h>
#define int long long
#define matsuri pair<int,int>
//const int iris = 1e9+7;
const int iris = 998244353;
using namespace std;

map<char, int> dd;

struct sagiri
{
	int n;
	vector<int> arr;
	vector<int> owo;
	vector<int> st;
	vector<int> tag;
	sagiri(const vector<int> &a)
	{
		n=a.size();
		arr=a;
		owo.resize(n*4);
		st.resize(n*4);
		tag.resize(n*4);
	}
	void build(int i,int l,int r, vector<int> & brr)
	{
		if(l==r)
		{
			owo[i]=arr[l];
			st[i]=(arr[l]==brr[l]);
		}
		else
		{
			int m=l+(r-l)/2;
			build(i*2,l,m,brr);
			build(i*2+1,m+1,r,brr);
			if(owo[i*2]==owo[i*2+1])
				owo[i]=owo[i*2];
			else
				owo[i]=4;
			st[i]=st[i*2]&st[i*2+1];
		}
		//cout<<' '<<i<<' '<<l<<' '<<r<<' '<<st[i]<<'\n';
	}
	void push(int i,int l,int r)
	{
		if(!tag[i] || l==r)
			return;
		l=i*2, r=i*2+1;
		tag[l]=tag[r]=tag[i];
		st[l]=(owo[l]==tag[i]);
		st[r]=(owo[r]==tag[r]);
		tag[i]=0;
	}
	void mdf(int i,int l,int r,int L,int R,int x)
	{
		push(i,l,r);
		int m=l+(r-l)/2;
		if(L<=l && r<=R)
		{
			st[i]=(owo[i]==x), tag[i]=x;
			return;
		}
		if(L<=m)
			mdf(i*2,l,m,L,R,x);
		if(R>m)
			mdf(i*2+1,m+1,r,L,R,x);
		st[i]=st[i*2]&st[i*2+1];
	}
};

void solve()
{
	dd['J']=1;
	dd['O']=2;
	dd['I']=3;
	int n;
	cin>>n;
	vector<vector<int> > owo;
	set<vector<int> > st;
	auto pr=[&](vector<int> v)
	{
		for(int x:v)
			cout<<x;
		cout<<'\n';
	};
	auto pp=[&](string s)
	{
		vector<int> res;
		for(char c:s)
			res.emplace_back(dd[c]);
		return res;
	};
	for(int i=0;i<3;i++)
	{
		string s;
		cin>>s;
		auto v=pp(s);
		st.insert(v);
		owo.emplace_back(v);
	}
	auto cal=[&](vector<int> a,vector<int> b)
	{
		for(int i=0;i<a.size();i++)
			a[i]=(6-a[i]+1-b[i]+1)%3+1;
		return a;
	};
	while(1)
	{
		bool flag=0;
		int n=owo.size();
		for(int i=0;i<n;i++)
		{
			for(int j=i;j<n;j++)
			{
				auto v=cal(owo[i], owo[j]);
				if(st.count(v)==0)
				{
					flag=1;
					st.insert(v);
					owo.emplace_back(v);
				}
			}
		}
		if(!flag)
			break;
	}
	
	vector<sagiri> sarina;
	int q;
	cin>>q;
	string s;
	cin>>s;
	auto brr=pp(s);
	bool ok=0;
	for(int i=0;i<owo.size();i++)
	{
		sarina.emplace_back(sagiri(owo[i]));
		sarina.back().build(1,0,n-1,brr);
		ok|=sarina.back().st[1];
		//pr(owo[i]);
	}
	if(ok)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	while(q--)
	{
		int l,r;
		char c;
		cin>>l>>r>>c;
		l--, r--;
		int x=dd[c];
		bool ok=0;
		for(auto &ss:sarina)
		{
			ss.mdf(1,0,n-1,l,r,x);
			ok|=ss.st[1];
		}
		if(ok)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
	
	int T=1;
	//cin>>T;
	while(T--)
		solve();
	
    return 0;
}

Compilation message

Main.cpp: In lambda function:
Main.cpp:104:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  104 |   for(int i=0;i<a.size();i++)
      |               ~^~~~~~~~~
Main.cpp: In function 'void solve()':
Main.cpp:136:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  136 |  for(int i=0;i<owo.size();i++)
      |              ~^~~~~~~~~~~
Main.cpp:81:7: warning: variable 'pr' set but not used [-Wunused-but-set-variable]
   81 |  auto pr=[&](vector<int> v)
      |       ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 86 ms 880 KB Output is correct
2 Correct 90 ms 848 KB Output is correct
3 Correct 93 ms 852 KB Output is correct
4 Correct 73 ms 1020 KB Output is correct
5 Correct 73 ms 852 KB Output is correct
6 Correct 73 ms 1020 KB Output is correct
7 Correct 76 ms 1108 KB Output is correct
8 Correct 75 ms 852 KB Output is correct
9 Correct 77 ms 908 KB Output is correct
10 Correct 78 ms 920 KB Output is correct
11 Correct 79 ms 884 KB Output is correct
12 Correct 80 ms 976 KB Output is correct
13 Correct 82 ms 852 KB Output is correct
14 Correct 77 ms 860 KB Output is correct
15 Correct 79 ms 1000 KB Output is correct
16 Correct 77 ms 848 KB Output is correct
17 Correct 78 ms 888 KB Output is correct
18 Correct 82 ms 848 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 86 ms 880 KB Output is correct
2 Correct 90 ms 848 KB Output is correct
3 Correct 93 ms 852 KB Output is correct
4 Correct 73 ms 1020 KB Output is correct
5 Correct 73 ms 852 KB Output is correct
6 Correct 73 ms 1020 KB Output is correct
7 Correct 76 ms 1108 KB Output is correct
8 Correct 75 ms 852 KB Output is correct
9 Correct 77 ms 908 KB Output is correct
10 Correct 78 ms 920 KB Output is correct
11 Correct 79 ms 884 KB Output is correct
12 Correct 80 ms 976 KB Output is correct
13 Correct 82 ms 852 KB Output is correct
14 Correct 77 ms 860 KB Output is correct
15 Correct 79 ms 1000 KB Output is correct
16 Correct 77 ms 848 KB Output is correct
17 Correct 78 ms 888 KB Output is correct
18 Correct 82 ms 848 KB Output is correct
19 Correct 472 ms 71084 KB Output is correct
20 Correct 359 ms 70920 KB Output is correct
21 Correct 309 ms 66884 KB Output is correct
22 Correct 284 ms 60476 KB Output is correct
23 Correct 143 ms 4780 KB Output is correct
24 Correct 157 ms 4664 KB Output is correct
25 Correct 321 ms 70980 KB Output is correct
26 Correct 327 ms 71072 KB Output is correct
27 Correct 379 ms 70992 KB Output is correct
28 Correct 396 ms 71012 KB Output is correct
29 Correct 351 ms 69012 KB Output is correct
30 Correct 166 ms 5428 KB Output is correct
31 Correct 358 ms 70924 KB Output is correct
32 Correct 377 ms 65168 KB Output is correct
33 Correct 144 ms 4428 KB Output is correct
34 Correct 373 ms 71080 KB Output is correct
35 Correct 263 ms 53400 KB Output is correct
36 Correct 139 ms 4404 KB Output is correct
37 Correct 144 ms 4408 KB Output is correct
38 Correct 302 ms 71004 KB Output is correct
39 Correct 160 ms 70932 KB Output is correct
40 Correct 277 ms 46592 KB Output is correct
41 Correct 530 ms 71160 KB Output is correct
42 Correct 66 ms 71204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 86 ms 880 KB Output is correct
2 Correct 90 ms 848 KB Output is correct
3 Correct 93 ms 852 KB Output is correct
4 Correct 73 ms 1020 KB Output is correct
5 Correct 73 ms 852 KB Output is correct
6 Correct 73 ms 1020 KB Output is correct
7 Correct 76 ms 1108 KB Output is correct
8 Correct 75 ms 852 KB Output is correct
9 Correct 77 ms 908 KB Output is correct
10 Correct 78 ms 920 KB Output is correct
11 Correct 79 ms 884 KB Output is correct
12 Correct 80 ms 976 KB Output is correct
13 Correct 82 ms 852 KB Output is correct
14 Correct 77 ms 860 KB Output is correct
15 Correct 79 ms 1000 KB Output is correct
16 Correct 77 ms 848 KB Output is correct
17 Correct 78 ms 888 KB Output is correct
18 Correct 82 ms 848 KB Output is correct
19 Correct 160 ms 1064 KB Output is correct
20 Correct 191 ms 952 KB Output is correct
21 Correct 92 ms 1124 KB Output is correct
22 Correct 75 ms 852 KB Output is correct
23 Correct 87 ms 912 KB Output is correct
24 Correct 84 ms 848 KB Output is correct
25 Correct 89 ms 1064 KB Output is correct
26 Correct 86 ms 1152 KB Output is correct
27 Correct 79 ms 880 KB Output is correct
28 Correct 69 ms 880 KB Output is correct
29 Correct 78 ms 848 KB Output is correct
30 Correct 74 ms 984 KB Output is correct
31 Correct 136 ms 1120 KB Output is correct
32 Correct 141 ms 1048 KB Output is correct
33 Correct 142 ms 1104 KB Output is correct
34 Correct 122 ms 924 KB Output is correct
35 Correct 137 ms 1024 KB Output is correct
36 Correct 139 ms 1144 KB Output is correct
37 Correct 146 ms 1344 KB Output is correct
38 Correct 138 ms 1108 KB Output is correct
39 Correct 137 ms 1108 KB Output is correct
40 Correct 138 ms 1108 KB Output is correct
41 Correct 138 ms 1108 KB Output is correct
42 Correct 138 ms 900 KB Output is correct
43 Correct 128 ms 872 KB Output is correct
44 Correct 146 ms 1368 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 86 ms 880 KB Output is correct
2 Correct 90 ms 848 KB Output is correct
3 Correct 93 ms 852 KB Output is correct
4 Correct 73 ms 1020 KB Output is correct
5 Correct 73 ms 852 KB Output is correct
6 Correct 73 ms 1020 KB Output is correct
7 Correct 76 ms 1108 KB Output is correct
8 Correct 75 ms 852 KB Output is correct
9 Correct 77 ms 908 KB Output is correct
10 Correct 78 ms 920 KB Output is correct
11 Correct 79 ms 884 KB Output is correct
12 Correct 80 ms 976 KB Output is correct
13 Correct 82 ms 852 KB Output is correct
14 Correct 77 ms 860 KB Output is correct
15 Correct 79 ms 1000 KB Output is correct
16 Correct 77 ms 848 KB Output is correct
17 Correct 78 ms 888 KB Output is correct
18 Correct 82 ms 848 KB Output is correct
19 Correct 472 ms 71084 KB Output is correct
20 Correct 359 ms 70920 KB Output is correct
21 Correct 309 ms 66884 KB Output is correct
22 Correct 284 ms 60476 KB Output is correct
23 Correct 143 ms 4780 KB Output is correct
24 Correct 157 ms 4664 KB Output is correct
25 Correct 321 ms 70980 KB Output is correct
26 Correct 327 ms 71072 KB Output is correct
27 Correct 379 ms 70992 KB Output is correct
28 Correct 396 ms 71012 KB Output is correct
29 Correct 351 ms 69012 KB Output is correct
30 Correct 166 ms 5428 KB Output is correct
31 Correct 358 ms 70924 KB Output is correct
32 Correct 377 ms 65168 KB Output is correct
33 Correct 144 ms 4428 KB Output is correct
34 Correct 373 ms 71080 KB Output is correct
35 Correct 263 ms 53400 KB Output is correct
36 Correct 139 ms 4404 KB Output is correct
37 Correct 144 ms 4408 KB Output is correct
38 Correct 302 ms 71004 KB Output is correct
39 Correct 160 ms 70932 KB Output is correct
40 Correct 277 ms 46592 KB Output is correct
41 Correct 530 ms 71160 KB Output is correct
42 Correct 66 ms 71204 KB Output is correct
43 Correct 160 ms 1064 KB Output is correct
44 Correct 191 ms 952 KB Output is correct
45 Correct 92 ms 1124 KB Output is correct
46 Correct 75 ms 852 KB Output is correct
47 Correct 87 ms 912 KB Output is correct
48 Correct 84 ms 848 KB Output is correct
49 Correct 89 ms 1064 KB Output is correct
50 Correct 86 ms 1152 KB Output is correct
51 Correct 79 ms 880 KB Output is correct
52 Correct 69 ms 880 KB Output is correct
53 Correct 78 ms 848 KB Output is correct
54 Correct 74 ms 984 KB Output is correct
55 Correct 136 ms 1120 KB Output is correct
56 Correct 141 ms 1048 KB Output is correct
57 Correct 142 ms 1104 KB Output is correct
58 Correct 122 ms 924 KB Output is correct
59 Correct 137 ms 1024 KB Output is correct
60 Correct 139 ms 1144 KB Output is correct
61 Correct 146 ms 1344 KB Output is correct
62 Correct 138 ms 1108 KB Output is correct
63 Correct 137 ms 1108 KB Output is correct
64 Correct 138 ms 1108 KB Output is correct
65 Correct 138 ms 1108 KB Output is correct
66 Correct 138 ms 900 KB Output is correct
67 Correct 128 ms 872 KB Output is correct
68 Correct 146 ms 1368 KB Output is correct
69 Correct 1479 ms 180928 KB Output is correct
70 Correct 1350 ms 215808 KB Output is correct
71 Correct 172 ms 5880 KB Output is correct
72 Correct 171 ms 5920 KB Output is correct
73 Correct 186 ms 6132 KB Output is correct
74 Correct 287 ms 62776 KB Output is correct
75 Correct 142 ms 4684 KB Output is correct
76 Correct 310 ms 74148 KB Output is correct
77 Correct 294 ms 62428 KB Output is correct
78 Correct 146 ms 4860 KB Output is correct
79 Correct 142 ms 4840 KB Output is correct
80 Correct 912 ms 154624 KB Output is correct
81 Correct 361 ms 11788 KB Output is correct
82 Correct 1090 ms 215628 KB Output is correct
83 Correct 1065 ms 202784 KB Output is correct
84 Correct 331 ms 11740 KB Output is correct
85 Correct 333 ms 11728 KB Output is correct
86 Correct 1286 ms 164512 KB Output is correct
87 Correct 1427 ms 215608 KB Output is correct
88 Correct 382 ms 11988 KB Output is correct
89 Correct 1212 ms 190312 KB Output is correct
90 Correct 1328 ms 215604 KB Output is correct
91 Correct 384 ms 12504 KB Output is correct
92 Correct 953 ms 162192 KB Output is correct
93 Correct 339 ms 11996 KB Output is correct
94 Correct 323 ms 11840 KB Output is correct
95 Correct 335 ms 11992 KB Output is correct
96 Correct 302 ms 70952 KB Output is correct
97 Correct 507 ms 215464 KB Output is correct
98 Correct 932 ms 141512 KB Output is correct
99 Correct 1933 ms 215948 KB Output is correct
100 Correct 209 ms 215724 KB Output is correct