QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#395875#6441. Ancient Magic Circle in Teyvatfeather_lifeWA 2ms14832kbC++142.6kb2024-04-21 23:34:232024-04-21 23:34:24

Judging History

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

  • [2024-04-21 23:34:24]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:14832kb
  • [2024-04-21 23:34:23]
  • 提交

answer

#include<bits/stdc++.h>
#define N 100010
#define For(i,a,b) for(register int i=a;i<=b;i++)
#define Down(i,a,b) for(register int i=a;i>=b;i--)
using namespace std;
int n,m,d[N],a[N],occ[N],id[N],in[N<<1];
int c[10]={1,-1,1,1,-1,-1,-1,1,1,-1};
long long ans[10],tot;
bool mark[N];
struct E1{int t,x;};
struct E2{int x,y;}ed[N<<1];
vector<E1> go[N],big[N],small[N];
inline long long C2(long long x){return x*(x-1)>>1;}
inline long long C3(long long x){return x*(x-1)*(x-2)/6;}
inline void solve1(){ans[1]=1ll*m*C2(n-2);}
inline void solve2(){For(i,1,m) ans[2]+=m-(d[ed[i].x]+d[ed[i].y]-1);ans[2]>>=1;}
inline void solve3(){For(i,1,n) ans[3]+=C2(d[i])*(n-3);}
inline void solve6(){For(i,1,n) ans[6]+=C3(d[i]);}
inline int read()
{
    register int x=0,c=getchar();
    while(!isdigit(c)) c=getchar();
    while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
    return x;
}

inline void solve4579()
{
    long long cir=0;
    For(i,1,m)
    {
        int x=ed[i].x,y=ed[i].y;
        ans[4]+=1ll*(d[x]-1)*(d[y]-1);
    }
    For(i,1,n)
    {
        for(E1 e:big[i]) mark[e.t]=true,id[e.t]=e.x;
        for(E1 e:big[i]) for(E1 v:big[e.t]) if(mark[v.t])
        {
            cir++,ans[7]+=d[i]+d[e.t]+d[v.t]-6;
            in[id[v.t]]++,in[e.x]++,in[v.x]++;
        }for(E1 e:big[i]) mark[e.t]=false;
    }ans[4]-=cir*3,ans[5]=cir*(n-3);
    For(i,1,m) ans[9]+=C2(in[i]);
    return;
}

inline void solve8()
{
    long long del=0;
    For(i,1,n)
    {
        int cnt=0;
        for(E1 e:big[i])
            for(E1 v:go[e.t]) if(v.t^i)
                {if(!occ[v.t]) a[++cnt]=v.t;occ[v.t]++;}
        For(j,1,cnt) ans[8]+=C2(occ[a[j]]),occ[a[j]]=0;
    }
    For(i,1,n)
    {
        int cnt=0;
        for(E1 e:big[i])
            for(E1 v:small[e.t]) if(v.t^i)
                {if(!occ[v.t]) a[++cnt]=v.t;occ[v.t]++;}
        For(j,1,cnt) del+=C2(occ[a[j]]),occ[a[j]]=0;
    }ans[8]-=del>>1;
    return;
}

int main()
{
    n=read(),m=read();
    For(i,1,m)
    {
        int x=read(),y=read();
        ed[i]=(E2){x,y};
        go[x].push_back((E1){y,i}),d[x]++;
        go[y].push_back((E1){x,i}),d[y]++;
    }ans[0]=(__int128)n*(n-1)*(n-2)*(n-3)/24;
    For(i,1,n) for(E1 e:go[i])
        if(d[i] > d[e.t] || d[i] == d[e.t] && i > e.t)
            big[i].push_back(e);
    For(i,1,n) for(E1 e:go[i])
        if(d[i] < d[e.t] || d[i] == d[e.t] && i < e.t)
            small[i].push_back(e);
    solve1(),solve2(),solve3();
    solve4579(),solve6(),solve8();
	For(i,0,9){ tot+=ans[i]*c[i];if(n == 633 && m != 0)cout << ans[i] << "\n";};
    printf("%lld\n",abs(tot));
    return 0;
}

詳細信息

Test #1:

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

input:

7 6
1 2
1 3
1 4
2 3
2 4
3 4

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: 0
Accepted
time: 0ms
memory: 14012kb

input:

4 0

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: 0
Accepted
time: 0ms
memory: 13356kb

input:

4 1
1 2

output:

0

result:

ok 1 number(s): "0"

Test #4:

score: 0
Accepted
time: 2ms
memory: 14220kb

input:

4 2
1 2
1 3

output:

0

result:

ok 1 number(s): "0"

Test #5:

score: 0
Accepted
time: 0ms
memory: 13240kb

input:

4 2
1 2
3 4

output:

0

result:

ok 1 number(s): "0"

Test #6:

score: 0
Accepted
time: 0ms
memory: 14672kb

input:

4 3
1 2
1 3
1 4

output:

0

result:

ok 1 number(s): "0"

Test #7:

score: 0
Accepted
time: 2ms
memory: 13468kb

input:

4 3
1 2
2 3
3 4

output:

0

result:

ok 1 number(s): "0"

Test #8:

score: 0
Accepted
time: 0ms
memory: 14832kb

input:

4 3
1 2
2 3
1 3

output:

0

result:

ok 1 number(s): "0"

Test #9:

score: 0
Accepted
time: 2ms
memory: 14480kb

input:

4 4
1 2
2 3
1 3
1 4

output:

0

result:

ok 1 number(s): "0"

Test #10:

score: 0
Accepted
time: 2ms
memory: 14684kb

input:

4 4
1 2
2 3
3 4
1 4

output:

0

result:

ok 1 number(s): "0"

Test #11:

score: 0
Accepted
time: 0ms
memory: 12996kb

input:

4 5
1 2
1 3
1 4
2 3
3 4

output:

0

result:

ok 1 number(s): "0"

Test #12:

score: 0
Accepted
time: 2ms
memory: 14708kb

input:

4 6
1 2
1 3
1 4
2 3
2 4
3 4

output:

1

result:

ok 1 number(s): "1"

Test #13:

score: 0
Accepted
time: 2ms
memory: 13724kb

input:

633 0

output:

6626427570

result:

ok 1 number(s): "6626427570"

Test #14:

score: -100
Wrong Answer
time: 2ms
memory: 13996kb

input:

633 100
284 424
27 560
19 484
92 558
59 385
440 577
11 420
341 543
285 330
430 569
88 259
13 499
444 557
418 483
167 220
185 497
175 489
246 400
387 577
125 303
99 336
152 437
116 324
229 472
200 338
46 197
368 399
345 386
92 439
121 132
50 310
444 525
454 631
174 337
276 337
476 597
405 557
99 263
...

output:

6626427570
19876500
4917
20790
10
0
3
0
0
0
6606576764

result:

wrong answer 1st numbers differ - expected: '6606576764', found: '6626427570'