UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#212282#3811. T1connection029ms1304kbC++1.3kb2024-10-13 17:28:522024-10-13 19:37:54

answer

// #pragma GCC optimize(1)
// #pragma GCC optimize(2)
// #pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
// #include <bits/extc++.h>
// using namespace __gnu_cxx;
// using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define mod ll(1e9+7)
int t,opt,d,a,b;
struct node{
	int a,b;
};
#define fastin ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
bool operator<(const node &a,const node &b){
	if(a.a!=b.a)return a.a<b.a;
	return a.b<b.b;
}
map<node,int>l,c;
int main(){
	fastin;
	cin>>t;
	while(t--){
		cin>>opt>>d>>a>>b;
		if(opt == 1){
			if(d == 0)l[(node){a,b}]++;
			if(d == 1)c[(node){a,b}]++;
		}else{
			if(d == 0)l[(node){a,b}]--;
			if(d == 1)c[(node){a,b}]--;
		}
		if(l.size() == 0 || c.size() == 0){
			cout<<-1<<endl;
			continue;
		}
		int ans = INT_MAX;
//		for(auto i:l)printf("[(%d,%d),%d]",i.first.a,i.first.b,i.second);cout<<endl;
//		for(auto i:c)printf("[(%d,%d),%d]",i.first.a,i.first.b,i.second);cout<<endl;
		for (map<node,int>::iterator i = l.begin(); i != l.end(); ++i){
			if(i->second <= 0)continue;
			for (map<node,int>::iterator j = c.begin(); j != c.end(); ++j){
				if(j->second <= 0)continue;
				int res = max(i->first.a+j->first.a,i->first.b+j->first.b);
				if(ans > res) ans = res;
				else break;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

详细

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

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 1264kb

input:

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

output:

-1
-1
2147483647
1553853033
2147483647
2147483647
2147483647
1372223954
1160777349
1160777349
787718...

result:

wrong answer 3rd numbers differ - expected: '-1', found: '2147483647'

Subtask #2:

score: 0
Wrong Answer

Test #2:

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

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 30th numbers differ - expected: '651052355', found: '755551180'

Subtask #3:

score: 0
Wrong Answer

Test #3:

score: 0
Wrong Answer
time: 10ms
memory: 1300kb

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
831398858
1022941456
1158731251
462065303
462065303
2147483647
2147483647
4079...

result:

wrong answer 11th numbers differ - expected: '-1', found: '2147483647'

Subtask #4:

score: 0
Wrong Answer

Test #4:

score: 0
Wrong Answer
time: 9ms
memory: 1304kb

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 120th numbers differ - expected: '241154242', found: '395355621'

Subtask #5:

score: 0
Wrong Answer

Test #5:

score: 0
Wrong Answer
time: 8ms
memory: 1304kb

input:

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

output:

-1
-1
-1
-1
2147483647
2147483647
2147483647
1033130556
2147483647
2147483647
596121801
596121801
57...

result:

wrong answer 5th numbers differ - expected: '-1', found: '2147483647'

Subtask #6:

score: 0
Time Limit Exceeded

Test #6:

score: 0
Time Limit Exceeded

input:

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

output:

-1
1226427981
1226427981
2147483647
1156522405
1156522405
907552725
851482156
851482156
851482156
85...

result:


Subtask #7:

score: 0
Time Limit Exceeded

Test #7:

score: 0
Time Limit Exceeded

input:

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

output:

-1
-1
-1
-1
2147483647
1369535428
1182928863
1182928863
2147483647
568524713
568524713
568524713
568...

result:


Subtask #8:

score: 0
Time Limit Exceeded

Test #8:

score: 0
Time Limit Exceeded

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
2147483647
770546713
770546713
1082209730
1082209730
1082209730
108220...

result:


Subtask #9:

score: 0
Time Limit Exceeded

Test #9:

score: 0
Time Limit Exceeded

input:

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

output:

-1
1479751141
1473776465
2147483647
2147483647
1484975949
1433383436
1331359936
1074242658
865998205...

result:


Subtask #10:

score: 0
Time Limit Exceeded

Test #10:

score: 0
Time Limit Exceeded

input:

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

output:

-1
1333027155
2147483647
2147483647
1118403184
1355417469
1355417469
1140899234
1085347521
107847800...

result: