QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#370758 | #6354. 4 | by_chance | WA | 2ms | 8536kb | C++14 | 1.4kb | 2024-03-29 16:08:30 | 2024-03-29 16:08:31 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
const int N=1e5+5;
int n,m,id[N];pair<int,int> x[N];
vector<int> G[N];vector<ull> bs[N];ull ans;
void upd(vector<ull>&f,int x){f[x>>6]|=1ull<<(x&63);}
int count(vector<ull>&f,vector<ull>&g){
int res=0;
for(int i=0;i<f.size();i++)
res+=__builtin_popcountll(f[i]&g[i]);
return res;
}
int main(){
scanf("%d%d",&n,&m);
for(int i=1,u,v;i<=m;i++){
scanf("%d%d",&u,&v);
G[u].push_back(v);G[v].push_back(u);
}
for(int i=1;i<=n;i++)x[i]={G[i].size(),i};
for(int i=1;i<=n;i++){
sort(G[i].begin(),G[i].end(),[&](int a,int b){return x[a]<x[b];});
while(G[i].size()&&x[G[i].back()]>x[i])G[i].pop_back();
}
for(int i=1;i<=n;i++)id[i]=-1;
for(int u=1;u<=n;u++){
int tot=0;for(int v:G[u])id[v]=tot++;
for(int l=0;l<tot;l+=10000){
int r=min(tot,l+10000),len=r-l;
for(int v:G[u]){
bs[id[v]].resize((len>>6)+1);
for(auto w:G[v])if(id[w]>=l&&id[w]<r)
upd(bs[id[v]],id[w]-l);
}
for(int v:G[u])for(int w:G[v])if(id[w]!=-1)
ans+=count(bs[id[v]],bs[id[w]]);
for(int v:G[u])bs[id[v]].clear();
}
for(int v:G[u])id[v]=-1;
}
printf("0 0 0 %lld\n",ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 8536kb
input:
5 9 1 2 1 3 1 4 1 5 2 3 2 4 2 5 3 4 3 5
output:
0 0 0 2
result:
wrong answer 1st numbers differ - expected: '2', found: '0'