QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#370614 | #6354. 4 | Lynkcat | WA | 1ms | 5996kb | C++17 | 1.4kb | 2024-03-29 13:49:32 | 2024-03-29 13:49:33 |
Judging History
answer
#include<bits/stdc++.h>
#define poly vector<int>
#define IOS ios::sync_with_stdio(false)
#define ll long long
#define mp make_pair
#define mt make_tuple
#define pa pair < int,int >
#define fi first
#define se second
#define inf 1e18
#define mod 998244353
#define sz(x) (int)((x).size())
#define int ll
//#define N
using namespace std;
const int N=100005;
bitset<505>eg[505];
int n,m;
poly G[N];
int ans;
pa E[N];
int du[N],p[N],rk[N],id[N];
void BellaKira()
{
cin>>n>>m;
for (int i=1;i<=m;i++)
{
cin>>E[i].fi>>E[i].se;
auto [x,y]=E[i];
du[x]++,du[y]++;
}
for (int i=1;i<=n;i++) p[i]=i;
sort(p+1,p+n+1,[&](int x,int y)
{
return (du[x]<du[y]||du[x]==du[y]&&x<y);
});
for (int i=1;i<=n;i++) rk[p[i]]=i;
for (int i=1;i<=m;i++)
{
auto [x,y]=E[i];
x=rk[x],y=rk[y];
if (x>y) swap(x,y);
G[x].push_back(y);
}
for (int i=1;i<=n;i++)
sort(G[i].begin(),G[i].end());
for (int i=1;i<=n;i++)
{
int tot=0;
for (auto u:G[i])
{
id[u]=tot++;
}
for (auto u:G[i])
for (auto v:G[u])
if (id[v])
eg[id[u]][id[v]]=1;
for (int x=0;x<tot;x++)
for (int y=x+1;y<tot;y++)
if (eg[x][y])
ans+=(eg[x]&eg[y]).count();
for (int x=0;x<tot;x++) eg[x].reset();
for (auto u:G[i]) id[u]=0;
}
cout<<ans<<" "<<ans<<" "<<ans<<" "<<ans<<'\n';
}
signed main()
{
IOS;
cin.tie(0);
int T=1;
while (T--)
{
BellaKira();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5996kb
input:
5 9 1 2 1 3 1 4 1 5 2 3 2 4 2 5 3 4 3 5
output:
2 2 2 2
result:
wrong answer Output contains longer sequence [length = 4], but answer contains 1 elements