QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#728087 | #9573. Social Media | ucup-team5296# | WA | 16ms | 17040kb | C++20 | 1.6kb | 2024-11-09 14:31:37 | 2024-11-09 14:31:39 |
Judging History
answer
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <ctime>
#include <cstdio>
#include <random>
#include <vector>
#include <bitset>
#include <cassert>
#include <cstring>
#include <algorithm>
#define fi first
#define se second
#define MISAKA main
#define ll long long
#define eb emplace_back
#define pii pair<int,int>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define _rep(i,a,b) for(int i=a;i>=b;--i)
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define FIO(FILE) freopen(FILE".in","r",stdin),freopen(FILE".out","w",stdout)
using namespace std;
inline int read(){
char ch=getchar();int f=1,x=0;
while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
return x*f;
}
const int N=2e5+10,mod=998244353;
int n,k,m,w[N],vis[N];
vector<int> g[N];map<int,int> cnt[N];
void misaka(){
rep(i,1,k) vis[i]=w[i]=0,g[i].clear(),cnt[i].clear();
n=read(),m=read(),k=read();
rep(i,1,n) vis[read()]=1;
int c=0;
rep(i,1,m){
int u=read(),v=read();
if(u==v) w[u]++,c+=vis[u];
else{
g[u].eb(v),g[v].eb(u);
c+=vis[u]&&vis[v];
cnt[u][v]++,cnt[v][u]++;
}
}
rep(i,1,k)if(vis[i])
for(int j:g[i])if(!vis[j]) w[j]++;
int ans=0;
rep(i,1,k)if(!vis[i])for(int j:g[i])if(!vis[j])
ans=max(ans,c+w[i]+w[j]+cnt[i][j]);
sort(w+1,w+k+1,[](int x,int y){return x>y;});
ans=max(ans,c+w[1]+w[2]);
printf("%d\n",ans);
}
signed MISAKA(){
int T=read();
while(T--) misaka();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 17040kb
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:
9 5 1 1 1
result:
ok 5 number(s): "9 5 1 1 1"
Test #2:
score: -100
Wrong Answer
time: 16ms
memory: 16872kb
input:
10000 19 12 20 8 12 1 5 11 7 17 13 19 6 3 9 10 15 14 20 4 18 16 4 11 7 1 8 4 16 19 1 13 15 2 16 2 8 7 3 15 11 13 5 20 18 14 17 14 20 2 9 1 12 8 11 10 17 18 16 3 15 5 14 20 13 7 15 10 3 2 5 16 7 8 6 1 6 4 18 16 1 8 4 1 20 6 6 9 4 15 7 5 14 9 1 3 18 9 15 18 17 15 11 14 7 19 7 3 1 2 5 6 4 7 5 1 4 5 3 1...
output:
12 14 1 19 6 5 1 14 19 4 3 10 4 1 4 19 15 2 18 4 17 5 1 2 5 19 3 3 6 15 7 3 6 4 4 7 3 7 4 1 16 16 2 3 6 12 12 7 6 9 8 7 9 11 16 1 4 9 8 16 2 8 22 22 17 8 22 15 8 13 7 9 6 9 2 17 10 5 5 3 6 6 20 8 13 12 10 5 3 6 3 1 8 5 8 12 7 15 10 9 9 11 9 9 6 2 8 15 11 5 3 5 5 10 1 6 9 18 5 3 20 1 4 8 8 10 4 3 1 1...
result:
wrong answer 8th numbers differ - expected: '11', found: '14'