QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#478698#21403. 文艺平衡树WrongAnswer_90#WA 0ms6016kbC++205.2kb2024-07-15 10:13:382024-07-15 10:13:38

Judging History

你现在查看的是最新测评结果

  • [2024-07-15 10:13:38]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:6016kb
  • [2024-07-15 10:13:38]
  • 提交

answer

#include<bits/stdc++.h>
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define ll long long
#define lll __int128
#define fi first
#define se second
#define e emplace
#define eb emplace_back
#define db double
#define ef emplace_front
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vp vector<pii>
#define mp make_pair

//#define LOCALJUDGE
// #define int ll
bool ST;
static const ll MOD=998244353,Phi=998244352,inv2=499122177,Root=3,iRoot=332748118;
static const ll inf=1073741823,INF=4557430888798830399;
static const double eps=1e-8,pi=3.1415926535;
char in[1<<20],*p1=in,*p2=in;
using namespace std;
//#define getchar() (p1==p2&&(p2=(p1=in)+fread(in,1,1<<20,stdin),p1==p2)?EOF:*p1++)
struct tup{int x,y,z;tup(int X=0,int Y=0,int Z=0){x=X,y=Y,z=Z;}};
namespace FastIO
{
	template<typename T> inline void write(T x,char ch=' ')
	{
		if(is_same<char,T>::value)putchar(x);
		else
		{
			if(x<0)x=-x,putchar('-');
			static char st[25];int top=0;
			do{st[top++]=x%10+'0',x/=10;}while(x);
			while(top)putchar(st[--top]);
		}
		ch!='~'?putchar(ch):0;
	}
	inline void write(const char*x,char ch=' ')
	{
		for(int i=0;x[i]!='\0';++i)putchar(x[i]);
		ch!='~'?putchar(ch):0;
	}
	inline void read(char&s){do s=getchar();while(s=='\n'||s==' ');}
	inline void read(char s[])
	{
		int len=0;char st;
		do st=getchar();while(st=='\n'||st==' ');
		s[++len]=st,st=getchar();
		while(st!='\n'&&st!=' ')s[++len]=st,st=getchar();
		s[++len]='\0';
	}
	template<typename T> inline void read(T &s)
	{
		s=0;char ch=getchar();
		while((ch>'9'||ch<'0')&&ch!='-')ch=getchar();
		bool tf=(ch=='-')&&(ch=getchar());
		while((ch>='0')&&(ch<='9'))s=(s<<1)+(s<<3)+ch-'0',ch=getchar();
		s=(tf?-s:s);
	}
	template<typename T1,typename T2> inline void read(pair<T1,T2> &s){read(s.fi),read(s.se);}
	template<typename T,typename...Args> inline void write(T x,Args...args){write(x,'~'),write(args...);}
	template<typename T,typename...Args> inline void read(T&x,Args&...args){read(x),read(args...);}
}
using namespace FastIO;
namespace MTool
{
	inline int Cadd(int a,int b){return (ll)a+b>=MOD?(ll)a+b-MOD:a+b;}
	inline int Cdel(int a,int b){return a-b<0?a-b+MOD:a-b;}
	inline int Cmul(int a,int b){return 1ll*a*b%MOD;}
	inline int sqr(int a){return 1ll*a*a%MOD;}
	inline void Madd(int&a,int b){a=((ll)a+b>=MOD?(ll)a+b-MOD:a+b);}
	inline void Mdel(int&a,int b){a=(a-b<0?a-b+MOD:a-b);}
	inline void Mmul(int&a,int b){a=1ll*a*b%MOD;}
	template<typename T> inline bool Mmax(T&a,T b){return a<b?a=b,1:0;}
	template<typename T> inline bool Mmin(T&a,T b){return a>b?a=b,1:0;}
	template<typename...Args> inline void Madd(int&a,int b,Args...args){Madd(a,b),Madd(a,args...);}
	template<typename...Args> inline void Mmul(int&a,int b,Args...args){Mmul(a,b),Mmul(a,args...);}
	template<typename...Args> inline void Mdel(int&a,int b,Args...args){Mdel(a,b),Mdel(a,args...);}
	template<typename...Args> inline int Cadd(int a,int b,Args...args){return Cadd(Cadd(a,b),args...);}
	template<typename...Args> inline int Cmul(int a,int b,Args...args){return Cmul(Cmul(a,b),args...);}
	template<typename...Args> inline int Cdel(int a,int b,Args...args){return Cdel(Cdel(a,b),args...);}
	template<typename...Args,typename T> inline bool Mmax(T&a,T b,Args...args){return Mmax(a,b)|Mmax(a,args...);}
	template<typename...Args,typename T> inline bool Mmin(T&a,T b,Args...args){return Mmin(a,b)|Mmin(a,args...);}
	inline int power(int x,int y){int s=1;for(;y;y>>=1,Mmul(x,x))if(y&1)Mmul(s,x);return s;}
}
using namespace MTool;
namespace WrongAnswer_90
{
	namespace FHQ
	{
		#define ls(x) t[x].ls
		#define rs(x) t[x].rs
		int root,cnt;
		struct{int ls,rs,v,siz,tg,rd;}t[100010];
		inline int newnode(int x){++cnt,t[cnt].v=x,t[cnt].siz=1,t[cnt].rd=rand();return cnt;}
		inline void update(int p){t[p].siz=t[ls(p)].siz+t[rs(p)].siz+1;}
		inline void down(int p){t[p].tg^=1,swap(ls(p),rs(p));}
		inline void spread(int p){if(t[p].tg)down(ls(p)),down(rs(p)),t[p].tg=0;}
		void split(int now,int k,int&x,int&y)
		{
			if(!now)return x=y=0,void();
			spread(now);
			if(k<=t[ls(now)].siz)y=now,split(ls(y),k,x,ls(y));
			else x=now,split(rs(x),k-t[ls(now)].siz-1,rs(x),y);
			update(now);
		}
		int merge(int x,int y)
		{
			if(!x||!y)return x|y;
			if(t[x].rd>t[y].rd)return spread(x),rs(x)=merge(rs(x),y),update(x),x;
			return spread(y),ls(y)=merge(x,ls(y)),update(y),y;
		}
		int X,Y,Z;
		void print(int p){if(p)print(ls(p)),write(t[p].v),print(rs(p));}
		void reverse(int l,int r){split(root,r,Y,Z),split(Y,l-1,X,Y),down(Y),root=merge(merge(X,Y),Z);}
	}
	using namespace FHQ;
	int n,m;
	inline void mian()
	{
		read(n,m);int x,y;
		for(int i=1;i<=n;++i)root=merge(root,newnode(i));
		while(m--)read(x,y),reverse(x,y);
		print(root);
	}
}
bool ED;
signed main()
{
	// #ifdef LOCALJUDGE
//	freopen("ex_char8.in","r",stdin);
//	freopen("1.out","w",stdout);
	// #endif
	double st=clock();
	WrongAnswer_90::mian();
	double ed=clock();
	#ifndef LOCALJUDGE
 	cerr<<endl;
	#endif
 	cerr<<"Time: "<<ed-st<<" ms\n";
	#ifdef LOCALJUDGE
 	cerr<<"     ";
	#endif
 	cerr<<"Memory: "<<abs(&ST-&ED)/1024.0/1024.0<<" MB\n";
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 6016kb

input:

30 5
7 26
7 18
5 9
4 15
3 15

output:

1 2 4 17 16 15 6 5 19 20 21 22 23 18 3 24 25 26 14 13 12 11 10 9 8 7 27 28 29 30 

result:

wrong answer 1st lines differ - expected: '1 2 4 17 16 15 6 5 18 19 20 21...4 13 12 11 10 9 8 7 27 28 29 30', found: '1 2 4 17 16 15 6 5 19 20 21 22... 13 12 11 10 9 8 7 27 28 29 30 '