QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#150585#6354. 4275307894aWA 1ms7704kbC++141.2kb2023-08-25 21:14:202023-08-25 21:14:23

Judging History

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

  • [2023-08-25 21:14:23]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7704kb
  • [2023-08-25 21:14:20]
  • 提交

answer

#include<bits/stdc++.h>
#define Gc() getchar() 
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;using LL=__int128;
const int N=1e5+5,M=500+5,K=14348907+5,mod=998244353,Mod=mod-1;const db eps=1e-9;const ll INF=1e18+7;mt19937 rnd(time(0));
int n,m,In[N],X[N],Y[N],Id[N];vector<int> S[N];
bitset<M> f[M];
void Solve(){
	int i,j;scanf("%d%d",&n,&m);
	for(i=1;i<=m;i++) scanf("%d%d",&X[i],&Y[i]),In[X[i]]++,In[Y[i]]++;
	for(i=1;i<=m;i++){
		if(In[X[i]]>In[Y[i]]) swap(X[i],Y[i]);
		S[X[i]].emplace_back(Y[i]);
	} 
	ll ans=0;
	for(i=1;i<=n;i++){
		int Ct=0;
		for(int j:S[i]) Id[j]=++Ct;
		for(int j:S[i]) {
			for(int h:S[j]) if(Id[h]) f[Id[j]][Id[h]]=1;
		}
		for(int j:S[i]) {
			for(int h:S[j]) if(Id[h]) ans+=(f[Id[j]]&f[Id[h]]).count();
		}
	}
	printf("%lld\n",ans);
}
int main(){
	int t;
	// scanf("%d",&t);
	t=1;
	while(t--) Solve();
	cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 6292kb

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: 6304kb

input:

4 0

output:

0

result:

ok 1 number(s): "0"

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 7704kb

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:

20

result:

wrong answer 1st numbers differ - expected: '0', found: '20'