QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#840910 | #61. Cut Cut Cut! | lovely_ckj | WA | 2ms | 7888kb | C++14 | 1.5kb | 2025-01-03 09:43:43 | 2025-01-03 09:43:47 |
Judging History
answer
#include <iostream>
#include <cstdio>
#include <vector>
#include <random>
#include <cstdlib>
using namespace std;
const int S=100005,MS=25;
#define p 1000000007
int n,m;
vector<int> g[S];
mt19937 rnd(time(NULL));
int a[S][MS][MS],tmp[MS];
inline void add(int &x,int y)
{
x+=y;
if(x>=p) x-=p;
}
inline int qpow(int x,int y)
{
int res=1;
for(;y>0;y>>=1,x=1ll*x*x%p) res=y&1?1ll*res*x%p:res;
return res;
}
inline void ins(int a[MS][MS],int x[])
{
for(int i=1;i<=MS-3;i++)
{
if(x[i]==0) continue;
if(a[i][i]==0)
{
for(int j=1;j<=MS-3;j++) a[i][j]=x[j];
a[0][0]++;
break;
}
int ml=1ll*x[i]*qpow(a[i][i],p-2)%p;
for(int j=1;j<=MS-3;j++)
add(x[j],p-1ll*a[i][j]*ml%p);
}
}
int main()
{
scanf("%d%d",&n,&m);
for(int i=1;i<=m;i++)
{
int x,y;
scanf("%d%d",&x,&y);
g[x].push_back(y);
g[y].push_back(x);
}
for(int v:g[1])
{
for(int i=1;i<=MS-3;i++) a[1][1][i]=rnd()%p;
ins(a[v],a[1][1]);
}
for(int u=2;u<=n;u++)
{
printf("%d ",a[u][0][0]);
bool f=false;
for(int i=1;i<=MS-3;i++) tmp[i]=0;
for(int i=1;i<=MS-3;i++)
{
bool fl=false;
for(int j=1;j<=MS-3&&!fl;j++)
fl|=a[u][i][j]!=0;
if(fl)
{
f=true;
int x=rnd()%p;
for(int j=1;j<=MS-3;j++)
add(tmp[j],1ll*a[u][i][j]*x%p);
}
}
if(!f) continue;
for(int v:g[u])
{
int x=rnd()%p;
for(int i=1;i<=MS-3;i++) tmp[i]=1ll*tmp[i]*x%p;
ins(a[v],tmp);
}
}
printf("\n");
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 7308kb
input:
3 3 1 2 1 3 2 3
output:
1 2
result:
ok 2 number(s): "1 2"
Test #2:
score: 0
Accepted
time: 0ms
memory: 7408kb
input:
8 8 1 2 1 3 1 5 2 4 2 5 3 6 4 5 7 8
output:
1 1 1 2 1 0 0
result:
ok 7 numbers
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 7888kb
input:
20 70 3 18 14 16 8 10 5 7 2 14 10 18 14 15 17 19 18 20 4 6 3 20 16 17 6 7 6 17 6 19 5 19 12 16 18 19 13 19 13 19 8 9 15 17 8 9 1 7 5 18 6 14 2 17 4 20 12 16 9 20 2 7 6 19 12 13 6 7 1 5 19 20 9 14 13 14 16 17 17 20 9 16 1 6 12 15 2 8 1 3 4 19 1 4 9 13 14 15 15 20 17 18 14 19 13 14 2 5 7 14 7 18 10 16...
output:
0 1 1 1 2 3 0 0 0 0 1 0 1 2 2 2 3 4 4
result:
wrong answer 6th numbers differ - expected: '4', found: '3'