Submission #423573

# Submission time Handle Problem Language Result Execution time Memory
423573 2021-06-11T09:38:54 Z Knps4422 Crossing (JOI21_crossing) C++14
26 / 100
7000 ms 9516 KB
//#pragma optimization_level 3
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordset;
*/
#define fr first
#define sc second
#define vec vector
#define pb push_back
#define pii pair<int, int>
#define forn(x,y) for(int x = 1 ; x <= (int)y ; ++x)
#define all(x) (x).begin(),(x).end()
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
 
using namespace std;
 
typedef long long ll;
typedef unsigned int uint;
typedef pair<ll,ll> pll;
typedef complex<int> point;
const int nmax = 2005;
const ll linf = 1e18;
const ll mod = 998244353;
const int inf = 1e9+10;
const int sq = 5000;

pair <int,pair<int,int>> compune(pair <int,pair<int,int>> a , pair <int,pair<int,int>> b){
	pair <int,pair<int,int>> c;
	c.fr = (2*a.fr + 2*b.fr)%3;
	c.sc.fr = (2*a.sc.fr + 2*b.sc.fr)%3;
	c.sc.sc = (2*a.sc.sc + 2*b.sc.sc)%3;
	return c;
}
int wtf(char ch){
	return (ch == 'J'? 0 : (ch == 'O' ? 1 : 2));
}
int n, q;
string s1,s2,s3;
string t;
vec < vec<int>> reach;

string check(){
	for(auto vcvc : reach){
		for(int i = 0; i <= n; i++){
			if(i == n)return "Yes\n";
			if(vcvc[i] != wtf(t[i]))break;
		}
	}
	return "No\n";
}
int main(){
	cin >> n;

	cin >> s1 >> s2 >> s3;
	set < pair<int,pair<int,int>> > proc, nw;
	nw.insert({1,{0,0}});
	nw.insert({0,{1,0}});
	nw.insert({0,{0,1}});
	while(nw.size()){
		auto conf = *nw.begin();
		nw.erase(nw.begin());
		for(auto conf2 : proc){
			auto conf3 = compune(conf,conf2);
			if(proc.find(conf3) == proc.end() && nw.find(conf3) == nw.end() && conf3 != conf){
				nw.insert(conf3);
			}
		}
		proc.insert(conf);
	}
	for(auto conf : proc){
		vec <int> xd (n);
		for(int i = 0 ; i < n; i++){
			xd[i] += wtf(s1[i]) * conf.fr;
		}
		for(int i = 0 ; i < n; i++){
			xd[i] += wtf(s2[i]) * conf.sc.fr;
		}
		for(int i = 0 ; i < n; i++){
			xd[i] += wtf(s3[i]) * conf.sc.sc;
			xd[i] %= 3;
		}
		//cout << conf.fr << ' ' << conf.sc.fr << ' ' << conf.sc.sc << ':';
 		reach.pb(xd);
	}
	
	cin >> q;
	cin >> t;
	cout << check();
	while(q--){
		int l , r;
		char chch;
		cin >> l >> r >> chch;
		for(int i = l; i <= r; i++){
			t[i-1] = chch;
		}
		//cout << t << ' ';
		cout << check();
	}
}
# Verdict Execution time Memory Grader output
1 Correct 537 ms 820 KB Output is correct
2 Correct 532 ms 760 KB Output is correct
3 Correct 581 ms 860 KB Output is correct
4 Correct 536 ms 964 KB Output is correct
5 Correct 542 ms 744 KB Output is correct
6 Correct 509 ms 820 KB Output is correct
7 Correct 531 ms 936 KB Output is correct
8 Correct 539 ms 844 KB Output is correct
9 Correct 543 ms 888 KB Output is correct
10 Correct 559 ms 848 KB Output is correct
11 Correct 562 ms 836 KB Output is correct
12 Correct 543 ms 804 KB Output is correct
13 Correct 532 ms 1008 KB Output is correct
14 Correct 565 ms 964 KB Output is correct
15 Correct 538 ms 860 KB Output is correct
16 Correct 524 ms 964 KB Output is correct
17 Correct 546 ms 876 KB Output is correct
18 Correct 573 ms 960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 537 ms 820 KB Output is correct
2 Correct 532 ms 760 KB Output is correct
3 Correct 581 ms 860 KB Output is correct
4 Correct 536 ms 964 KB Output is correct
5 Correct 542 ms 744 KB Output is correct
6 Correct 509 ms 820 KB Output is correct
7 Correct 531 ms 936 KB Output is correct
8 Correct 539 ms 844 KB Output is correct
9 Correct 543 ms 888 KB Output is correct
10 Correct 559 ms 848 KB Output is correct
11 Correct 562 ms 836 KB Output is correct
12 Correct 543 ms 804 KB Output is correct
13 Correct 532 ms 1008 KB Output is correct
14 Correct 565 ms 964 KB Output is correct
15 Correct 538 ms 860 KB Output is correct
16 Correct 524 ms 964 KB Output is correct
17 Correct 546 ms 876 KB Output is correct
18 Correct 573 ms 960 KB Output is correct
19 Execution timed out 7052 ms 9516 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 537 ms 820 KB Output is correct
2 Correct 532 ms 760 KB Output is correct
3 Correct 581 ms 860 KB Output is correct
4 Correct 536 ms 964 KB Output is correct
5 Correct 542 ms 744 KB Output is correct
6 Correct 509 ms 820 KB Output is correct
7 Correct 531 ms 936 KB Output is correct
8 Correct 539 ms 844 KB Output is correct
9 Correct 543 ms 888 KB Output is correct
10 Correct 559 ms 848 KB Output is correct
11 Correct 562 ms 836 KB Output is correct
12 Correct 543 ms 804 KB Output is correct
13 Correct 532 ms 1008 KB Output is correct
14 Correct 565 ms 964 KB Output is correct
15 Correct 538 ms 860 KB Output is correct
16 Correct 524 ms 964 KB Output is correct
17 Correct 546 ms 876 KB Output is correct
18 Correct 573 ms 960 KB Output is correct
19 Correct 538 ms 804 KB Output is correct
20 Correct 567 ms 856 KB Output is correct
21 Correct 542 ms 840 KB Output is correct
22 Correct 534 ms 952 KB Output is correct
23 Correct 533 ms 860 KB Output is correct
24 Correct 541 ms 744 KB Output is correct
25 Correct 645 ms 836 KB Output is correct
26 Correct 569 ms 876 KB Output is correct
27 Correct 541 ms 880 KB Output is correct
28 Correct 507 ms 716 KB Output is correct
29 Correct 543 ms 872 KB Output is correct
30 Correct 515 ms 744 KB Output is correct
31 Correct 617 ms 836 KB Output is correct
32 Correct 541 ms 820 KB Output is correct
33 Correct 544 ms 880 KB Output is correct
34 Correct 486 ms 836 KB Output is correct
35 Correct 565 ms 868 KB Output is correct
36 Correct 537 ms 840 KB Output is correct
37 Correct 636 ms 792 KB Output is correct
38 Correct 584 ms 972 KB Output is correct
39 Correct 552 ms 824 KB Output is correct
40 Correct 527 ms 876 KB Output is correct
41 Correct 607 ms 872 KB Output is correct
42 Correct 608 ms 816 KB Output is correct
43 Correct 527 ms 804 KB Output is correct
44 Correct 533 ms 816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 537 ms 820 KB Output is correct
2 Correct 532 ms 760 KB Output is correct
3 Correct 581 ms 860 KB Output is correct
4 Correct 536 ms 964 KB Output is correct
5 Correct 542 ms 744 KB Output is correct
6 Correct 509 ms 820 KB Output is correct
7 Correct 531 ms 936 KB Output is correct
8 Correct 539 ms 844 KB Output is correct
9 Correct 543 ms 888 KB Output is correct
10 Correct 559 ms 848 KB Output is correct
11 Correct 562 ms 836 KB Output is correct
12 Correct 543 ms 804 KB Output is correct
13 Correct 532 ms 1008 KB Output is correct
14 Correct 565 ms 964 KB Output is correct
15 Correct 538 ms 860 KB Output is correct
16 Correct 524 ms 964 KB Output is correct
17 Correct 546 ms 876 KB Output is correct
18 Correct 573 ms 960 KB Output is correct
19 Execution timed out 7052 ms 9516 KB Time limit exceeded
20 Halted 0 ms 0 KB -