답안 #312028

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
312028 2020-10-12T07:33:26 Z wildturtle Interval Collection (CCO20_day2problem2) C++14
0 / 25
2171 ms 412168 KB
#include<bits/stdc++.h>
using namespace std;
int a,b,t,tree[2000020],treeL[2000020],treeR[2000020];
multiset <int> stl,str,msl[1000006],msr[1000006];
char ch;
#define tavi begin()
#define bolo rbegin()
void update(int node,int L,int R,int idx,int mxare) {
	if(idx<L || R<idx) return;
	if(L==R) {
		if(mxare) { if(msr[idx].empty()) treeR[node]=1e9; else treeR[node]=*msr[idx].tavi; }
		else { if(msl[idx].empty()) treeL[node]=-1e9; else treeL[node]=*msl[idx].bolo; }
		tree[node]=treeR[node]-treeL[node];
		return;
	}
	update(2*node,L,(L+R)/2,idx,mxare);
	update(2*node+1,(L+R)/2+1,R,idx,mxare);
	tree[node]=min(min(tree[2*node],tree[2*node+1]),treeR[2*node+1]-treeL[2*node]);
	treeL[node]=max(treeL[2*node],treeL[2*node+1]);
	treeR[node]=min(treeR[2*node],treeR[2*node+1]);
}
int main() {
	std::ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    for (int i=1;i<=2000010;i++) {
        tree[i]=2*1e9; treeL[i]=-1e9; treeR[i]=1e9;
    }
	cin>>t;
	while(t--) {
		cin>>ch>>a>>b;
		if(ch=='A') {
			stl.insert(a);
			str.insert(b);
			msl[b].insert(a);
			msr[a].insert(b);
			update(1,1,1e6+1,b,0);
			update(1,1,1e6+1,a,1);
		}
		else {
			stl.erase(stl.find(a));
			str.erase(str.find(b));
			msl[b].erase(a);
			msr[a].erase(b);
			update(1,1,1e6+1,b,0);
			update(1,1,1e6+1,a,1);
		}
		if(*(stl.bolo)<=*(str.tavi)) cout<<*(msr[*(stl.bolo)].tavi)-*(msl[*(str.tavi)].bolo)<<endl;
		else cout<<tree[1]<<endl;
	}
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 230 ms 238332 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 230 ms 238332 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 230 ms 238332 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 918 ms 155824 KB Output is correct
2 Correct 920 ms 155972 KB Output is correct
3 Correct 1731 ms 193796 KB Output is correct
4 Correct 1772 ms 193860 KB Output is correct
5 Runtime error 2171 ms 412168 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 230 ms 238332 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -