QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#754833#9623. 合成大西瓜Rosmontis_L#WA 0ms3628kbC++201.7kb2024-11-16 15:55:202024-11-16 15:55:21

Judging History

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

  • [2024-11-16 15:55:21]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3628kb
  • [2024-11-16 15:55:20]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
//#define int long long
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef tuple<ll, ll, ll> TLL;
int lowbit(int x) {return x & (- x);};
const int N = 200010, mod = 998244353;
const int Mod = 1e9 + 7, INF = 0x3f3f3f3f;

void solve(){
	int n, m; cin >> n >> m;
	vector<int> d(n + 1), a(n + 1);
	vector<vector<int>> g(n + 1);
	for(int i = 1; i <= n; i ++) cin >> a[i];
	for(int i = 1; i <= m; i ++) {
		int u, v; cin >> u >> v;
		d[u] ++, d[v] ++;
		g[u].push_back(v), g[v].push_back(u);
	}
	if(n == 1) {
		cout << a[1] << '\n';
		return ;
	}
	vector<int> odd, eve;
	for(int i = 1; i <= n; i ++) {
		if(g[i].size() == 1) {
			odd.push_back(a[i]);
			continue;
		}
		int o = 0, e = 0;
		for(auto j : g[i]) {
			int cnt = g[j].size() - 1;
			if(cnt & 1) o ++;
			else e ++; 
		}
		int t = g[i].size() - 2;
		t &= 1;
		if(t & 1) {
			if(o >= 1 && e >= 1) {
				eve.push_back(a[i]);
			}
			else odd.push_back(a[i]);	
		} else {
			if(o >= 2 || e >= 2) {
				eve.push_back(a[i]);
			}
			else odd.push_back(a[i]);
		}
	}
	int res = 0;
	for(auto x : eve) res = max(res, x);
	int mn = 1e9;
	for(auto x : odd) {
		mn = min(mn, x);
	}
	if(mn == 1e9) cout << res << '\n';
	else cout << max(res, mn) << '\n';
}
/*
7 7
1 1 2 3 1 2 1
1 2
2 3
1 3
2 4
2 5
5 6
5 7
*/
int main(){
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int t = 1;
//	cin >> t;
	while(t --){
		solve();
	}
//    fclose(stdin);
//    fclose(stdout);
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3592kb

input:

7 9
1 4 1 3 3 6 7
5 4
3 6
3 4
2 3
5 2
2 6
6 7
5 1
4 6

output:

6

result:

ok single line: '6'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3628kb

input:

5 7
1 5 3 1 4
3 5
1 3
5 1
1 4
5 4
2 4
3 2

output:

5

result:

ok single line: '5'

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3556kb

input:

7 7
2 4 2 3 3 6 7
5 1
2 6
5 3
4 6
1 6
1 2
2 7

output:

3

result:

wrong answer 1st lines differ - expected: '6', found: '3'