提交记录 7908


用户 题目 状态 得分 用时 内存 语言 代码长度
Metheus 1000. 测测你的 A+B Time Limit Exceeded 0 10 us 32 KB C++ 1.54 KB
提交时间 评测时间
2019-01-25 19:40:04 2020-08-01 01:10:09
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#define loop(n,i) for(register int i=1;i<=(n);++i)
#define zxc(x) cout<<(#x)<<'='<<(x)<<'\n'
#define zxcv(x) cout<<(#x)<<'='<<(x)<<','
#define MAX 3
using namespace std;
inline int icin() {
	int s=0;bool sign=0;char c=getchar();
	while(!isdigit(c)&&c^'-')c=getchar();
	if(c=='-')c=getchar();
	while(isdigit(c))s=(s<<1)+(s<<3)+c-'0',c=getchar();
	return sign?-s:s;
}

int c[MAX][2],f[MAX],rev[MAX],sum[MAX],val[MAX];
struct LCT{
	inline bool IsRoot(int x){return (c[f[x]][0]^x)&&(c[f[x]][1]^x);}
	inline void upload(int x){
		sum[x]=sum[c[x][0]]+sum[c[x][1]]+val[x];
	}
	inline void download(int x){
		if(rev[x]){
			rev[c[x][0]]^=1,rev[c[x][1]]^=1;rev[x]^=1;
			swap(c[x][0],c[x][1]);
		}
	}
	inline void Rot(int x){
		int fa=f[x],gf=f[fa],s=c[fa][1]==x,sn=c[x][s^1];
		if(!IsRoot(fa)) c[gf][c[gf][1]==fa]=x;f[x]=gf;
		f[c[fa][s]=sn]=fa,f[c[x][s^1]=fa]=x;
		upload(fa);
	}
	inline void Splay(int x){
		download(x);
		while(!IsRoot(x)){
			int fa=f[x],gf=f[fa];
			download(gf),download(fa),download(x);
			if(!IsRoot(fa)) (c[gf][1]==fa)==(c[fa][1]==x)?Rot(fa):Rot(x);
			Rot(x);
		}
		upload(x);
	}
	inline void Access(int x){
		int y=0;
		while(x){
			Splay(x);
			c[x][1]=y;
			upload(x);
			y=x,x=f[x];
		}
	}
	inline void MakeRoot(int x){Access(x),Splay(x),rev[x]^=1;}
	inline void Link(int x,int y){MakeRoot(x),f[x]=y;}
	inline void GetChain(int x,int y){MakeRoot(x),Access(y),Splay(y);}
}L;

int plus(int a, int b)
{
	val[1]=icin(),val[2]=icin();
	L.Link(1,2);
	L.GetChain(1,2);
	return sum[2];
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #110 us32 KBTime Limit ExceededScore: 0


Judge Duck Online | 评测鸭在线
Server Time: 2026-04-07 16:02:57 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠