比赛 2025.12.20 评测结果 AATTTWWTWWWWWW
题目名称 《图》 最终得分 14
用户昵称 汐汐很希希 运行时间 12.537 s
代码语言 C++ 内存使用 4.18 MiB
提交时间 2025-12-20 10:06:30
显示代码纯文本
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1010;
const int M=0;
const int MOD=998244353;
const int MAXX=2e9;
ll n,m,color[N],ans=0;
/*vector<ll> g[N];
vector<ll> e[N];
void add(ll x,ll y,ll w=0){
	g[x].push_back(y);
	e[x].push_back(w);
}*/
bool g[N][N];
void dfs(int u)
{
	if(u>n){
		ans=(ans+1)%MOD;
		return;
	}
	for(int i=1;i<=n;i++){
        bool nei=false;
        for(int v=1;v<u;v++){
            if(g[u][v]&&color[v]==i){
                nei=true;
                break;
            }
        }
        if(!nei){
            color[u]=i;
            dfs(u+1);
        }
    }
}
int main()
{
	freopen("graphh.in","r",stdin);
	freopen("graphh.out","w",stdout);
	
	cin>>n>>m;
	if(n>1000){
		cout<<"ciallo~"<<endl;
		return 0;
	}
	for(int i=1;i<=m;i++){
		int u,v;
		cin>>u>>v;
		g[u][v]=g[v][u]=true;
	}
	while(1){
        bool ad[N][N]={false};
        bool flag=false;
        for(int a=1;a<=n;a++){
            for(int b=a+1;b<=n;b++){
                for(int c=b+1;c<=n;c++){
                    if(g[a][b]&&g[a][c]&&!g[b][c]){
                        ad[b][c]=true;
                        ad[c][b]=true;
                        flag=true;
                    }
                }
            }
        }
        if(!flag) break;
        for(int u=1;u<=n;u++)
            for(int v=1;v<=n;v++)
                if(ad[u][v]) g[u][v]=true;
    }
	dfs(1);
	cout<<ans<<endl; 
	return 0;
}