QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#326564#1411. Communication Jammingsocpite0 2ms7960kbC++202.4kb2024-02-13 14:07:062024-02-13 14:07:07

Judging History

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

  • [2024-02-13 14:07:07]
  • 评测
  • 测评结果:0
  • 用时:2ms
  • 内存:7960kb
  • [2024-02-13 14:07:06]
  • 提交

answer


// #include "assistant.h"
#include<bits/stdc++.h>
using namespace std;

const int maxn = 2e5+5;
const int INF = 1e9+5;

map<int, vector<pair<int, int>>> g1, g2;

int n, m1, m2, q;

int X1[maxn], Y1[maxn];
int X2[maxn], Y2[maxn];

bool cmp1(pair<int, int> a, pair<int, int> b){
	return min(X1[a.first], X1[a.second]) < min(X1[b.first], X1[b.second]); 
}

bool cmp2(pair<int, int> a, pair<int, int> b){
	return min(X2[a.first], X2[a.second]) < min(X2[b.first], X2[b.second]); 
}

int up[maxn];
pair<int, int> rg[maxn];
multiset<int> ms;
int t[maxn];

int Find(int x){
	if(!up[x])return x;
	else return up[x] = Find(up[x]); 
}

void Union(int a, int b, int md, int y){
	a = Find(a);
	b = Find(b);
	if(b > n){
		up[b] = a;
		return;
	}
	if(rg[a].first > rg[b].first)swap(a, b);
	if(md == 1)t[rg[a].second] = y;
	else {
		if(ms.find(t[rg[a].second]) == ms.end())cout << "SUS" << endl;
		else ms.erase(ms.find(t[rg[a].second]));
	}
	up[b] = a;
	rg[a].second = rg[b].second;
}

vector<pair<int, int>> ans;

int main(){
	cin >> n >> m1 >> m2 >> q;
	for(int i = 1; i <= n; i++){
		X1[i] = X2[i] = i;
	}
	for(int i = 1; i <= m1; i++){
		cin >> X1[i + n] >> Y1[i + n];
	}
	for(int i = 0; i < n + m1 - 1; i++){
		int ty, a, b;
		cin >> ty >> a >> b;
		if(ty == 1)g1[max(Y1[a], Y1[b+n])].push_back({a, b+n});
		else g1[max(Y1[a+n], Y1[b+n])].push_back({a+n, b+n});
	}
	g1[0].push_back({0, 0});
	g1[0].clear();

	for(int i = 1; i <= m2; i++){
		cin >> X2[i + n] >> Y2[i + n];
		Y2[i+n] *= -1;
	}
	for(int i = 0; i < n + m2 - 1; i++){
		int ty, a, b;
		cin >> ty >> a >> b;
		if(ty == 1)g2[max(Y2[a], Y2[b+n])].push_back({a, b+n});
		else g2[max(Y2[a+n], Y2[b+n])].push_back({a+n, b+n});
	}
	// cout << "SUS" << endl;
	memset(up, 0, sizeof(up));
	for(int i = 1; i <= n; i++)rg[i] = {i, i};
	for(auto ele: g2){
		auto vec = ele.second;
		sort(vec.begin(), vec.end(), cmp2);
		for(auto v: vec)Union(v.first, v.second, 1, ele.first);
	}
	for(int i = 1; i <= n; i++)ms.insert(t[i]);
	memset(up, 0, sizeof(up));
	for(int i = 1; i <= n; i++)rg[i] = {i, i};
	for(auto ele: g1){
		auto vec = ele.second;
		sort(vec.begin(), vec.end(), cmp1);
		for(auto v: vec)Union(v.first, v.second, 0, ele.first);
		ans.push_back({ele.first, *ms.rbegin()});
		// cout << *ms.rbegin() << endl;
	}
	while(q--){
		int x;
		cin >> x;
		cout << -(*(lower_bound(ans.begin(), ans.end(), make_pair(x, INF))-1)).second << "\n";
	}

}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

input:

100 99 99 100
40 71
79 29
1 20
88 54
70 38
77 30
31 12
79 81
84 34
17 65
68 57
40 2
14 22
56 3
15 17
11 75
36 77
52 7
30 91
82 13
19 64
44 14
63 41
38 18
99 84
22 49
68 39
64 63
99 93
8 48
66 10
6 83
45 35
94 37
58 87
89 15
71 4
75 60
59 42
74 62
56 59
82 73
90 24
76 95
36 21
91 67
33 31
13 79
20 50...

output:

SUS
SUS
SUS
SUS
SUS
SUS
SUS
SUS
SUS
SUS
SUS
SUS
SUS
SUS
SUS
SUS
SUS
SUS
SUS
SUS
SUS
SUS
SUS
SUS
-88
-88
-88
-88
-88
-93
-88
-88
-88
-88
-88
-93
-88
-88
-88
-88
-88
-88
-88
-88
-88
-88
-93
-88
-88
-88
-88
-88
-88
-88
-88
-88
-88
-88
-88
-88
-88
-88
-88
-93
-88
-88
-88
-88
-88
-88
-88
-88
-88
-88
-88
...

result:

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

Subtask #2:

score: 0
Skipped

Dependency #1:

0%