QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#881742#5098. 第一代图灵机STARSczy0 84ms31744kbC++142.7kb2025-02-04 17:43:322025-02-04 17:43:34

Judging History

This is the latest submission verdict.

  • [2025-02-04 17:43:34]
  • Judged
  • Verdict: 0
  • Time: 84ms
  • Memory: 31744kb
  • [2025-02-04 17:43:32]
  • Submitted

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=1e6+10,mod=1e9+7;
inline int read(){
	int n=0,x=0,c;
	while((c=getchar())<'0'||c>'9') x=c=='-'; 
	do (n*=10)+=c-'0';while((c=getchar())>='0'&&c<='9');
	return x?-n:n;
}
inline int write(int n){
	if(n<0) putchar('-'),n=-n;
	if(n>9) write(n/10);
	putchar('0'+n%10);
	return n;
}

int n=read(),m=read(),c=read(),t[maxn];
map<pair<int,int>,int> odt;
pair<int,int> split(int x){
	if(x>n) return {0,0};
	auto it=prev(odt.upper_bound({x,n+1}))->first;
	auto w=odt[it];
	if(it.first==x) return it;
	odt.erase(it),odt[{it.first,x-1}]=w,odt[{x,it.second}]=w;
	return {x,it.second};
}

struct sgtree{
	struct node{
		int data,size,sum,mx,mn,vis;
		node *l,*r;
	}*root,*a=0,*b=0,*c=0;
	node* newnode(int n){
		node *p=new node;
		p->data=p->sum=p->mx=p->mn=n,p->size=1,p->vis=rand(),p->l=p->r=0;
		return p;
	}
	node *pushup(node *p){
		p->sum=p->mx=p->mn=p->data,p->size=1;
		if(p->l) p->sum+=p->l->sum,p->size+=p->l->size,p->mx=max(p->mx,p->l->mx),p->mn=min(p->mn,p->l->mn);
		if(p->r) p->sum+=p->r->sum,p->size+=p->r->size,p->mx=max(p->mx,p->r->mx),p->mn=min(p->mn,p->r->mn);
		return p;
	}
	void split(node *id,int val,node *&l,node *&r){
		if(!id) return (void)(l=r=0);
		int ls=0;
		if(id->l) ls=id->l->size;
		if(val<=ls) r=id,split(id->l,val,l,id->l);
		else l=id,split(id->r,val-(ls+1),id->r,r);
		pushup(id);
	}
	node* merge(node *l,node *r){
		if(!l||!r) return l?l:r;
		if(l->vis<r->vis) return l->r=merge(l->r,r),pushup(l);
		return r->l=merge(l,r->l),pushup(r);
	}
	int sum(int l,int r){
		int ans=0;
		split(root,r,b,c),split(b,l-1,a,b);
		if(b) ans=b->sum;
		root=merge(a,merge(b,c));
		return ans;
	}
	int mx(int l,int r){
		int ans=9;
		split(root,r,b,c),split(b,l-1,a,b);
		if(b) ans=b->mx;
		root=merge(a,merge(b,c));
		return ans;
	}
	int mn(int l,int r){
		int ans=9;
		split(root,r,b,c),split(b,l-1,a,b);
		if(b) ans=b->mn;
		root=merge(a,merge(b,c));
		return ans;
	}
	void change(int id,int x){split(root,id,b,c),split(b,id-1,a,b),root=merge(merge(a,newnode(x)),c),delete b;}
	void insert(int x){root=merge(root,newnode(x));}
}a;

signed main(){
	for(int i=1;i<=n;++i) a.insert(read());
	for(int i=1;i<=n;++i) odt[{i,i}]=read();
	for(int o=1;o<=m;++o){
		int opt=read();
		if(opt==2){
			int id=read(),x=read();
			a.change(id,x);
		}
		else if(opt==1){
			int l=read(),r=read(),x=read();
			auto rs=split(r+1),ls=split(l);
			for(auto i=odt.find(ls);i!=odt.end()&&i->first!=rs;++i,odt.erase(prev(i)));
			odt.insert({{l,r},x});
		}
	}
	return 0;
}/*
10 10 3
6533 6747 3607 2602 3294 2826 7913 6827 7790 4191
1 1 1 3 1 2 2 1 2 3
1 7 590
4 4 5
2 7 8 2
2 8 8 2
3 4 5
1 6 4014
3 6 7
3 3 9
3 1 5
4 4 10

*/

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 4352kb

input:

5000 200 5000
2315 3433 1793 4621 4627 4561 289 4399 3822 2392 392 4581 2643 2441 4572 4649 2981 3094 4206 2057 761 2516 2849 3509 3033 658 4965 3316 3269 4284 4961 753 1187 2515 1377 1725 4743 4761 3823 3464 4859 989 2401 953 875 1481 2181 103 2067 2625 3296 4721 61 3843 1607 997 4385 1284 4299 441...

output:


result:

wrong answer 1st lines differ - expected: '118571', found: ''

Subtask #2:

score: 0
Wrong Answer

Test #3:

score: 0
Wrong Answer
time: 71ms
memory: 31744kb

input:

200000 10 200000
55651 97298 108697 86619 60721 199951 10610 162267 154301 138848 39191 18605 101369 57073 34977 101576 71252 143401 89587 160521 166491 38442 150761 35579 25571 121311 38033 38483 144639 41401 179161 54872 157905 137601 46863 187656 171901 43715 41036 150741 69057 102031 130561 4772...

output:


result:

wrong answer 1st lines differ - expected: '1232419', found: ''

Subtask #3:

score: 0
Wrong Answer

Test #5:

score: 0
Wrong Answer
time: 84ms
memory: 31488kb

input:

200000 20000 200000
30681 32496 35471 48191 159123 69792 120915 150673 187226 158493 36275 26856 107976 124777 145229 69745 183961 14497 144808 153612 185893 137681 66417 46802 19345 113322 168046 128149 191001 135433 13201 139214 59489 81178 42343 163158 110121 119201 97501 53079 158755 192241 1132...

output:


result:

wrong answer 1st lines differ - expected: '46702944', found: ''

Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%