답안 #881316

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
881316 2023-12-01T06:26:36 Z arashMLG Crossing (JOI21_crossing) C++17
0 / 100
68 ms 23780 KB
#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 psJ[N],psO[N],psI[N];

struct node {
	int ans;
	int J,O,I;
	int L,R;
	char lz = '-';
	
	void set(char c) {
		if(c == 'J') {
			ans = psJ[R] - psJ[L-1];
			J = R-L+1;
			O=0;
			I = 0;
		} else if (c == 'O') {
			ans = psO[R] - psO[L-1];
			O = R-L+1;
			J=0;
			I = 0;
		} else {
			ans = psI[R] - psI[L-1];
			I = R-L+1;
			O=0;
			J = 0;
		}
		lz = 'c';
	}
	
	void merge(node a,node b) {
		ans = a.ans + b.ans;
		J = a.J + b.J;
		O = a.O + b.O;
		I = a.I + b.I;
	}
} t[N<<2];

int n,q;
string s,beg;

void shift(int v) {
	if(t[v].lz == '-') return;
	t[lc].set(t[v].lz);
	t[rc].set(t[v].lz);
	t[v].lz = '-';
}

void build(int v=1,int tl=1,int tr = n+3) {
	t[v].L = tl,t[v].R = tr-1; t[v].lz= '-';
	if(tr-tl==1) {
		t[v].set(beg[tl]);
		debug(tl,beg.substr(tl,1),s.substr(tl,1));
		return;
	}
	int mid=(tl+tr)/2;
	build(lc,tl,mid);
	build(rc,mid,tr);
	t[v].merge(t[lc],t[rc]);
}

void upd(int l,int r,char c,int v=1,int tl=1,int tr= n+3) {
	if(l > r) return;
	if(l == tl && r == tr-1) {
		t[v].set(c);
		return;
	}
	shift(v);
	int mid=(tl+tr)/2;
	upd(l,min(mid-1,r),c,lc,tl,mid);
	upd(max(l,mid),r,c,rc,mid,tr);
	t[v].merge(t[lc],t[rc]);
}

int32_t main() {
    cin.tie(nullptr)->sync_with_stdio(false);
	cin>>n>>s>>s>>s; s= "#" + s;
	for(int i = 1; i<= n ; i++) {
		psJ[i] = psJ[i-1] + (s[i] == 'J');
		psO[i] = psO[i-1] + (s[i] == 'O');
		psI[i] = psI[i-1] + (s[i] == 'I');
	}
	cin>>q;
	cin>>beg; beg = "#" + beg;
	build();
	cout<< (t[1].ans == n ? "Yes" : "No") << '\n';
	debug(t[1].ans);
	while(q--) {
		int l,r; char c; cin>>l>>r>>c;
		upd(l,r,c);
		debug(t[1].ans);
		cout<< (t[1].ans == n ? "Yes" : "No") << '\n';
	}
	return 0;
}

Compilation message

Main.cpp: In function 'void build(int, int, int)':
Main.cpp:5:20: warning: statement has no effect [-Wunused-value]
    5 | #define debug(...) 69
      |                    ^~
Main.cpp:74:3: note: in expansion of macro 'debug'
   74 |   debug(tl,beg.substr(tl,1),s.substr(tl,1));
      |   ^~~~~
Main.cpp: In function 'int32_t main()':
Main.cpp:5:20: warning: statement has no effect [-Wunused-value]
    5 | #define debug(...) 69
      |                    ^~
Main.cpp:108:2: note: in expansion of macro 'debug'
  108 |  debug(t[1].ans);
      |  ^~~~~
Main.cpp:5:20: warning: statement has no effect [-Wunused-value]
    5 | #define debug(...) 69
      |                    ^~
Main.cpp:112:3: note: in expansion of macro 'debug'
  112 |   debug(t[1].ans);
      |   ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 23652 KB Output is correct
2 Correct 66 ms 23780 KB Output is correct
3 Correct 68 ms 23644 KB Output is correct
4 Incorrect 66 ms 23632 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 23652 KB Output is correct
2 Correct 66 ms 23780 KB Output is correct
3 Correct 68 ms 23644 KB Output is correct
4 Incorrect 66 ms 23632 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 23652 KB Output is correct
2 Correct 66 ms 23780 KB Output is correct
3 Correct 68 ms 23644 KB Output is correct
4 Incorrect 66 ms 23632 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 23652 KB Output is correct
2 Correct 66 ms 23780 KB Output is correct
3 Correct 68 ms 23644 KB Output is correct
4 Incorrect 66 ms 23632 KB Output isn't correct
5 Halted 0 ms 0 KB -