QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#395874 | #6441. Ancient Magic Circle in Teyvat | feather_life | Compile Error | / | / | C++14 | 2.6kb | 2024-04-21 23:33:55 | 2024-04-21 23:33:56 |
Judging History
This is the latest submission verdict.
- [2024-04-21 23:33:56]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-04-21 23:33:55]
- Submitted
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;
}
Details
answer.code: In function ‘int main()’: answer.code:88:37: error: expected ‘;’ before ‘if’ 88 | For(i,0,9){ tot+=ans[i]*c[i]if(n == 633 && m != 0)cout << ans[i] << "\n";}; | ^~ | ;