Submission #930434
Source Code Expand
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
struct Union_Find{
int d[SIZE],num[SIZE];
void init(int n){
REP(i,n)d[i]=i,num[i]=1;
}
int find(int x){
return (x!=d[x])?(d[x]=find(d[x])):x;
}
bool uu(int x,int y){
x=find(x);
y=find(y);
if(x==y)return 0;
if(num[x]<=num[y]){
num[y]+=num[x];
d[x]=y;
}
else{
num[x]+=num[y];
d[y]=x;
}
return 1;
}
}U;
VPII e[100];
bool used[100];
PII from[100];
void ADD(LL& x,LL v){
x=(x+v)%MOD;
}
int h[100];
void dfs(int x){
used[x]=1;
REP(i,SZ(e[x])){
int y=e[x][i].F;
if(used[y]){
if(h[y]<h[x]){
int id=e[x][i].S;
int now=x;
while(now!=y){
U.uu(id,from[now].S);
now=from[now].F;
}
}
}
else{
from[y]=MP(x,e[x][i].S);
h[y]=h[x]+1;
dfs(y);
}
}
}
LL dp0[111][111];
PII ee[222];
LL mypow(LL x,LL y){
x%=MOD;
LL res=1%MOD;
while(y){
if(y&1)res=res*x%MOD;
y>>=1;
x=x*x%MOD;
}
return res;
}
LL f(int n,int K){
LL v=0;
REPP(i,1,n+1){
int gg=__gcd(i,n);
ADD(v,mypow(K,gg));
}
v=v*mypow(n,MOD-2)%MOD;
return v;
}
int main(){
DRIII(N,M,K);
dp0[0][0]=1;
REP(i,K){
REP(j,111){
if(dp0[i][j]){
for(int k=0;k+j<111;k++){
ADD(dp0[i+1][j+k],dp0[i][j]);
}
}
}
}
U.init(M);
REP(i,M){
DRII(x,y);x--;y--;
ee[i]=MP(x,y);
e[x].PB(MP(y,i));
e[y].PB(MP(x,i));
}
REP(i,N)
if(!used[i])dfs(i);
LL an=1;
REP(i,M){
if(U.find(i)==i){
//printf("[%d,%d]\n",i,U.num[i]);
if(U.num[i]==1)an=an*K%MOD;
else{
set<int>P;
REP(j,M){
if(U.find(j)==i){P.insert(ee[j].F);P.insert(ee[j].S);}
}
if(SZ(P)<U.num[i])an=an*dp0[K][U.num[i]]%MOD;
else{
an=an*f(U.num[i],K)%MOD;
}
}
}
}
cout<<an<<endl;
return 0;
}
Submission Info
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:104:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
DRIII(N,M,K);
^
./Main.cpp:117:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
DRII(x,y);x--;y--;
^
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
1300 / 1300 |
Status |
|
|
Set Name |
Test Cases |
Sample |
0_000.txt, 0_001.txt, 0_002.txt |
All |
0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt, 1_018.txt, 1_019.txt, 1_020.txt, 1_021.txt, 1_022.txt, 1_023.txt, 1_024.txt, 1_025.txt, 1_026.txt, 1_027.txt, 1_028.txt, 1_029.txt, 1_030.txt, 1_031.txt, 1_032.txt, 1_033.txt, 1_034.txt, 1_035.txt, 1_036.txt, 1_037.txt, 1_038.txt, 1_039.txt, 1_040.txt, 1_041.txt, 1_042.txt, 1_043.txt, 1_044.txt, 1_045.txt, 1_046.txt, 1_047.txt, 1_048.txt, 1_049.txt, 1_050.txt, 1_051.txt, 1_052.txt, 1_053.txt, 1_054.txt, 1_055.txt, 1_056.txt, 1_057.txt, 1_058.txt, 1_059.txt, 1_060.txt, 1_061.txt, 1_062.txt, 1_063.txt |
Case Name |
Status |
Exec Time |
Memory |
0_000.txt |
AC |
3 ms |
256 KB |
0_001.txt |
AC |
3 ms |
256 KB |
0_002.txt |
AC |
3 ms |
256 KB |
1_003.txt |
AC |
2 ms |
256 KB |
1_004.txt |
AC |
4 ms |
384 KB |
1_005.txt |
AC |
4 ms |
384 KB |
1_006.txt |
AC |
4 ms |
384 KB |
1_007.txt |
AC |
3 ms |
256 KB |
1_008.txt |
AC |
3 ms |
256 KB |
1_009.txt |
AC |
3 ms |
256 KB |
1_010.txt |
AC |
3 ms |
256 KB |
1_011.txt |
AC |
3 ms |
256 KB |
1_012.txt |
AC |
3 ms |
256 KB |
1_013.txt |
AC |
3 ms |
256 KB |
1_014.txt |
AC |
4 ms |
384 KB |
1_015.txt |
AC |
4 ms |
384 KB |
1_016.txt |
AC |
4 ms |
384 KB |
1_017.txt |
AC |
4 ms |
384 KB |
1_018.txt |
AC |
4 ms |
384 KB |
1_019.txt |
AC |
4 ms |
384 KB |
1_020.txt |
AC |
4 ms |
384 KB |
1_021.txt |
AC |
4 ms |
384 KB |
1_022.txt |
AC |
4 ms |
384 KB |
1_023.txt |
AC |
4 ms |
384 KB |
1_024.txt |
AC |
4 ms |
384 KB |
1_025.txt |
AC |
4 ms |
384 KB |
1_026.txt |
AC |
4 ms |
384 KB |
1_027.txt |
AC |
4 ms |
384 KB |
1_028.txt |
AC |
2 ms |
256 KB |
1_029.txt |
AC |
3 ms |
256 KB |
1_030.txt |
AC |
2 ms |
256 KB |
1_031.txt |
AC |
2 ms |
256 KB |
1_032.txt |
AC |
3 ms |
256 KB |
1_033.txt |
AC |
3 ms |
256 KB |
1_034.txt |
AC |
3 ms |
256 KB |
1_035.txt |
AC |
3 ms |
256 KB |
1_036.txt |
AC |
4 ms |
384 KB |
1_037.txt |
AC |
4 ms |
384 KB |
1_038.txt |
AC |
4 ms |
384 KB |
1_039.txt |
AC |
4 ms |
384 KB |
1_040.txt |
AC |
3 ms |
256 KB |
1_041.txt |
AC |
3 ms |
256 KB |
1_042.txt |
AC |
3 ms |
256 KB |
1_043.txt |
AC |
2 ms |
256 KB |
1_044.txt |
AC |
3 ms |
256 KB |
1_045.txt |
AC |
3 ms |
256 KB |
1_046.txt |
AC |
3 ms |
256 KB |
1_047.txt |
AC |
3 ms |
256 KB |
1_048.txt |
AC |
4 ms |
384 KB |
1_049.txt |
AC |
4 ms |
384 KB |
1_050.txt |
AC |
4 ms |
384 KB |
1_051.txt |
AC |
4 ms |
384 KB |
1_052.txt |
AC |
2 ms |
256 KB |
1_053.txt |
AC |
3 ms |
256 KB |
1_054.txt |
AC |
3 ms |
256 KB |
1_055.txt |
AC |
3 ms |
256 KB |
1_056.txt |
AC |
3 ms |
256 KB |
1_057.txt |
AC |
2 ms |
256 KB |
1_058.txt |
AC |
2 ms |
256 KB |
1_059.txt |
AC |
3 ms |
256 KB |
1_060.txt |
AC |
4 ms |
384 KB |
1_061.txt |
AC |
4 ms |
384 KB |
1_062.txt |
AC |
4 ms |
384 KB |
1_063.txt |
AC |
4 ms |
384 KB |