rt.
我在P2819 RE 了 #3,下载测试点后我找到了错误,修改了代码如下。
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define fo(i,l,r) for(int i=l;i<=r;i++)
#define fd(i,r,l) for(int i=r;i>=l;i--)
using namespace std;
int n,k,m,u,v,ans,col[105];
bool b[105][105];
bool check(int x){
fo(i,1,x)
if(b[i][x]&&col[i]==col[x])return 0;
return 1;
}
void dfs(int x){
if(x>n){
ans++;
return;
}
fo(i,1,m){
col[x]=i;
if(check(x))dfs(x+1);
else col[x]=0;
}
col[x]=0;
}
int main(){
cin>>n>>k>>m;
fo(i,1,k){
cin>>u>>v;
b[u][v]=b[v][u]=1;
}
dfs(1);
cout<<ans;
return 0;
}
这份代码在洛谷ide里测试输出的是 0,但在 Dev-c++ 里 freopen 后输出的却是 1。
有大佬可以帮我解释一下这是什么原因吗?