UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#212210#3811. T1x_add_b03278ms16828kbC++11940b2024-10-13 14:55:032024-10-13 19:35:10

answer

#include<bits/stdc++.h>

namespace IO
{
	template<typename Type>
	void read(Type &x){
		char ch=getchar();
		x=0;bool f=0;
		while(ch<'0'||ch>'9')
			f|=(ch=='-'),ch=getchar();
		while(ch>='0'&&ch<='9')
			x=((x<<1)+(x<<3)+(ch^48)),ch=getchar();
		x=f?-x:x;
	}
}

using namespace std;

int opt,d,a,b,T;

struct node
{
	int A,B;
	bool operator < (const node &a) const
	{
		return max(A,B)<max(a.A,a.B);
	}
};

multiset<node> L,C;

void solve()
{
	IO::read(opt);IO::read(d);IO::read(a);IO::read(b);
	if(opt){
		if(!d) L.insert({a,b});
		else C.insert({a,b});
	}else{
		if(!d&&L.count({a,b})) L.erase({a,b});
		else if(C.count({a,b})) C.erase({a,b});
	}
	if(L.empty()||C.empty()){puts("-1");return;}
	auto cur1=*L.begin(),cur2=*C.begin();
	int ax=cur1.A,bx=cur1.B,ay=cur2.A,by=cur2.B;
	printf("%lld\n",max(1ll*ax+1ll*ay,1ll*bx+1ll*by));
}

int main()
{
	IO::read(T);
	while(T--)
		solve();
}

详细

小提示:点击横条可展开更详细的信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

input:

100
1 0 30056910 791979446
0 0 30056910 791979446
1 1 87818006 915325879
1 0 885405412 638527154
0 1...

output:

-1
-1
-1
1553853033
-1
-1
-1
1372223954
1160777349
1160777349
787718936
787718936
1160777349
-1
-1
-...

result:

wrong answer 41st numbers differ - expected: '613474114', found: '658987775'

Subtask #2:

score: 0
Wrong Answer

Test #2:

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

input:

100
1 0 888145469 920169409
1 0 452904566 455699108
1 0 9314511 72429163
0 0 452904566 455699108
1 1...

output:

-1
-1
-1
-1
560615725
560615725
560615725
560615725
560615725
738065491
738065491
1439446683
8215374...

result:

wrong answer 32nd numbers differ - expected: '593491753', found: '651052355'

Subtask #3:

score: 0
Wrong Answer

Test #3:

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

input:

1000
1 0 434052041 886975755
1 0 5735137 42531708
1 0 333067530 62734547
0 0 434052041 886975755
1 1...

output:

-1
-1
-1
-1
839243210
839243210
1022941456
1158731251
462065303
462065303
-1
-1
407960422
407960422
...

result:

wrong answer 6th numbers differ - expected: '831398858', found: '839243210'

Subtask #4:

score: 0
Wrong Answer

Test #4:

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

input:

1000
1 1 99608765 102738517
1 0 409526489 651778959
1 1 632469167 447766999
1 1 596595729 295223176
...

output:

-1
754517476
754517476
754517476
754517476
754517476
240180556
240180556
240180556
240180556
7545174...

result:

wrong answer 55th numbers differ - expected: '366330184', found: '381650369'

Subtask #5:

score: 0
Wrong Answer

Test #5:

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

input:

1000
1 1 392884476 341683390
1 1 812391583 884023296
0 1 392884476 341683390
0 1 812391583 884023296...

output:

-1
-1
-1
-1
-1
-1
-1
1033130556
-1
-1
596121801
596121801
572006216
572006216
572006216
572006216
57...

result:

wrong answer 35th numbers differ - expected: '541724549', found: '572006216'

Subtask #6:

score: 0
Wrong Answer

Test #6:

score: 0
Wrong Answer
time: 223ms
memory: 4284kb

input:

200000
1 0 745208991 893565181
1 1 338915529 332862800
1 1 879402360 343669571
0 0 745208991 8935651...

output:

-1
1226427981
1226427981
-1
1156522405
1156522405
1156522405
851482156
851482156
851482156
851482156...

result:

wrong answer 7th numbers differ - expected: '907552725', found: '1156522405'

Subtask #7:

score: 0
Wrong Answer

Test #7:

score: 0
Wrong Answer
time: 204ms
memory: 4280kb

input:

200000
1 0 61288090 442363511
1 0 702180888 491607485
0 0 702180888 491607485
0 0 61288090 442363511...

output:

-1
-1
-1
-1
-1
1369535428
1182928863
1182928863
-1
568524713
568524713
724241738
568524713
566451066...

result:

wrong answer 12th numbers differ - expected: '568524713', found: '724241738'

Subtask #8:

score: 0
Wrong Answer

Test #8:

score: 0
Wrong Answer
time: 198ms
memory: 4344kb

input:

200000
1 0 965089945 885763418
1 0 47734550 558904612
0 0 47734550 558904612
1 0 511007140 115554736...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
770546713
770546713
1082209730
1082209730
1082209730
1082209730
108...

result:

wrong answer 44th numbers differ - expected: '555816350', found: '727427688'

Subtask #9:

score: 0
Wrong Answer

Test #9:

score: 0
Wrong Answer
time: 1440ms
memory: 16816kb

input:

1000000
1 1 598963903 48224788
1 0 880787238 21153517
1 0 874812562 609964051
0 1 598963903 48224788...

output:

-1
1479751141
1473776465
-1
-1
1484975949
1433383436
1433383436
1358486159
865998205
981267655
98126...

result:

wrong answer 8th numbers differ - expected: '1331359936', found: '1433383436'

Subtask #10:

score: 0
Wrong Answer

Test #10:

score: 0
Wrong Answer
time: 1212ms
memory: 16828kb

input:

1000000
1 0 532848699 733617288
1 1 59884418 599409867
0 1 59884418 599409867
1 0 1137393 496603003
...

output:

-1
1333027155
-1
-1
1118403184
1355417469
1355417469
1140899234
1140899234
1134029719
1140899234
672...

result:

wrong answer 9th numbers differ - expected: '1085347521', found: '1140899234'