QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#315999 | #6354. 4 | wangqingxian | WA | 7ms | 12040kb | C++20 | 2.4kb | 2024-01-27 16:54:02 | 2024-01-27 16:54:03 |
Judging History
answer
//#pragma GCC optimize(2)
#include<algorithm>
#include<stdlib.h>
#include<iostream>
#include<cassert>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<vector>
#include<cstdio>
#include<random>
#include<bitset>
#include<queue>
#include<cmath>
#include<set>
#include<map>
//#include<bits/stdc++.h>
#define uint unsigned int
#define int long long
#define ll long long
#define ull unsigned long long
#define uint unsigned int
#define lll __int128
#define db double
#define ld long double
#define pii pair<int,int>
#define For(i,l,r) for(int i=(l);i<=(r);++i)
#define rof(i,r,l) for(int i=(r);i>=(l);--i)
#define mem0(a) memset(a,0,sizeof(a))
#define meminf(a) memset(a,0x3f,sizeof(a))
#define lowbit(t) (t&-t)
#define ckmax(a,b) a=max(a,b)
#define ckmin(a,b) a=min(a,b)
#define ppct(t) __builtin_popcount(t)
//#define x1 xxx111
//#define y1 yyy111
//#define x2 xxx222
//#define y2 yyy222
using namespace std;
const int N=1e5+10,inf=1e18,mod=1e9+7;
int deg[N];
vector<int>e1[N];
int vis[N];
int triangle(vector<pii>vec,int n){
int ans=0;
For(i,1,n){
deg[i]=0;
e1[i].clear();
}
for(auto [u,v]:vec){++deg[u];++deg[v];}
for(auto [u,v]:vec){
if(deg[u]<deg[v]||(deg[u]==deg[v]&&u<v))
e1[u].push_back(v);
else
e1[v].push_back(u);
}
For(x,1,n){
for(auto y:e1[x])vis[y]=x;
for(auto y:e1[x])for(auto z:e1[y]){
if(vis[z]==x)++ans;
}
}
return ans;
}
int n,m;
int du[N];
vector<int>e[N];
int u[N],v[N];
vector<pii>vec;
int id[N];
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
cin>>n>>m;
For(i,1,m){
cin>>u[i]>>v[i];
++du[u[i]];
++du[v[i]];
}
For(i,1,m){
if(du[u[i]]<du[v[i]]||(du[u[i]]==du[v[i]]&&u[i]<v[i]))
e[u[i]].push_back(v[i]);
else
e[v[i]].push_back(u[i]);
}
int ans=0;
For(i,1,n){
int tot=0;
for(auto x:e[i])id[x]=++tot;
vec.clear();
for(auto x:e[i])
for(auto y:e[x])
if(id[y])
vec.push_back({id[x],id[y]});
ans+=triangle(vec,e[i].size());
for(auto x:e[i])id[x]=0;
}
cout<<ans<<endl;
return 0;
}
/*
5 9
1 2
1 3
1 4
1 5
2 3
2 4
2 5
3 4
3 5
*/
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 9720kb
input:
5 9 1 2 1 3 1 4 1 5 2 3 2 4 2 5 3 4 3 5
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 1ms
memory: 5628kb
input:
4 0
output:
0
result:
ok 1 number(s): "0"
Test #3:
score: 0
Accepted
time: 1ms
memory: 7904kb
input:
50 50 28 35 12 24 31 50 10 24 21 44 5 31 23 36 31 45 6 39 4 8 13 37 42 48 17 45 19 33 12 21 19 32 16 43 12 47 25 31 40 48 8 49 43 48 6 42 27 34 13 39 17 40 13 35 3 49 20 24 5 12 43 44 15 37 24 27 8 43 4 22 17 38 28 47 29 46 3 15 9 49 1 41 43 45 3 6 37 48 13 30 11 43 8 25 33 38 16 32 32 41
output:
0
result:
ok 1 number(s): "0"
Test #4:
score: 0
Accepted
time: 7ms
memory: 8184kb
input:
100 4900 64 78 3 13 93 96 48 64 34 64 5 76 66 74 44 78 17 20 30 73 5 34 24 100 23 65 4 70 22 95 47 70 6 89 15 70 70 82 88 90 29 80 27 64 16 59 28 99 67 68 85 99 37 85 8 46 71 78 40 95 6 21 27 66 16 89 11 83 17 57 19 36 21 70 27 86 27 45 5 56 10 64 23 33 87 91 37 40 21 55 75 79 54 96 3 77 70 78 36 93...
output:
3689634
result:
ok 1 number(s): "3689634"
Test #5:
score: -100
Wrong Answer
time: 5ms
memory: 12040kb
input:
100 4000 73 78 38 98 9 65 43 72 20 47 6 37 49 60 48 87 48 77 23 100 57 59 42 99 40 88 20 96 19 44 35 80 12 93 34 44 63 75 3 49 32 99 47 61 3 13 54 81 55 96 16 74 28 77 43 45 25 92 5 82 3 83 9 55 64 78 39 89 19 64 58 75 1 18 22 76 16 55 18 60 14 55 29 96 37 97 26 97 11 53 24 79 7 35 53 54 31 74 31 32...
output:
1094307
result:
wrong answer 1st numbers differ - expected: '1094294', found: '1094307'