QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#760280#9573. Social MediaHaijieTanWA 0ms3524kbC++232.6kb2024-11-18 15:59:002024-11-18 15:59:00

Judging History

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

  • [2024-11-18 15:59:00]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3524kb
  • [2024-11-18 15:59:00]
  • 提交

answer

#include<iostream>
#include<vector>
#include<bitset>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<numeric>//iota -- iota(all(a), x) a从头到尾从x开始递增
#include<cstring>
#include<ctime>
#include<array>
#include<list> 
#include<random>
#include<tuple>
#include<deque>
#include<map>
#include<stack>
#include<set>
using namespace std;
#define IOS ios::sync_with_stdio(false);cin.tie(0), cout.tie(0)
#define int long long
#define all(x) x.begin(), x.end()
#define pb push_back
#define pf push_front
#define lowbit(x) (x & (-x))
const int xy[][2] = { 0,1, 0, -1, 1, 0, -1, 0 };
#define mem(a, x) memset(a, x, sizeof a)
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef pair<char, char> PCC;
typedef pair<int, char> PIC;
typedef pair<char, int> PCI;
#define x first
#define y second
#define NO cout << "NO\n"
#define YES cout << "YES\n"
#define Yes cout << "Yes\n"
#define No cout << "No\n"
inline int read();
const int INF = 1e9, N = 1e4 + 10, MOD = 998244353, M = 1e4 + 10, K = 1331;
const double PI = acos(-1.0);
void solve() {
	int n, m, k; cin >> n >> m >> k;
	map<int, int>mp, vis;//, cnt1;
	map<PII, int>chong;
	vector<vector<int>>g(k + 2);
	for (int i = 1; i <= n; i++) {
		int x; cin >> x;
		mp[x] = 1;
	}
	int ret = 0;
	for (int i = 1; i <= m; i++) {
		int u, v; cin >> u >> v;
		chong[{u, v}]++;
		if(u != v)chong[{v, u}]++;
		g[u].pb(v), g[v].pb(u);
		if (mp[u] && mp[v])ret++;
		else if (mp[u])vis[v]++;//, cnt1[u]++;
		else if (mp[v])vis[u]++;//, cnt1[v]++;
	}
	int d1 = -1, d2 = -1;
	// for(auto [x, y]:cnt1){
	// 	if(y > d1)d2 = d1, d1 = y;
	// 	else if(y > d2)d2 = y;
	// }
	auto getAns = [&](int u, int v) -> int {
		return vis[u] + vis[v] + chong[{u, v}];
		};
	int cnt = 0;//max(0ll, d1) + max(0ll, d2);
	for (int i = 1; i <= k; i++) {
		if (!mp[i]) {
			// cout << i << '?' << vis[i] << ' ';
			if (vis[i] > d1)d2 = d1, d1 = vis[i];
			else if (vis[i] > d2)d2 = vis[i];
			for (auto to : g[i]) {
				if (!mp[to]) {
					cnt = max(cnt, getAns(i, to));
				}
			}
		}
	}
	// cout << endl;
	cnt = max(cnt, max(0ll, d1) + max(0ll, d2));
	// cout << d1 << ' ' << d2 <<endl;
	cout << cnt + ret << endl;
}
signed main() {
    IOS;
    int _ = 1;
    cin >> _;
    while (_--)solve();
    return 0;
}
inline int read()
{
    int x = 0, f = 1; char ch = getchar();
    while (ch < '0' || ch>'9') { if (ch == '-') f = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') { x = x * 10 + ch - 48; ch = getchar(); }
    return x * f;
}
/*   /\_/\
*   (= ._.)
*   / >  \>
*/

详细

Test #1:

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

input:

5
4 12 7
5 7 3 6
3 6
2 2
1 4
2 4
1 3
7 6
4 1
5 4
1 1
1 1
2 1
3 7
2 7 6
2 4
1 2
3 2
2 5
5 4
2 6
4 6
2 6
1 1 2
1
1 2
2 1 2
1 2
1 2
2 1 100
24 11
11 24

output:

7
5
1
1
1

result:

wrong answer 1st numbers differ - expected: '9', found: '7'