Run ID Author Problem Lang Verdict Time Memory Code Length Submit Time
44555 zht2002 田忌赛马 C++ Accepted 0 MS 252 KB 666 2024-03-31 08:53:56

Tests(2/2):


#include<iostream> #include<cstdio> #include<algorithm> using namespace std; const int N=10; int a[N]; int b[N]; int n,x; int vis[N]; int check(){ int res=0; for(int i=1;i<=n;i++){ if(b[i]>=a[i]+x){ res++; } } if(2*res>n) return 1; return 0; } void dfs(int cur){ if(cur==n+1){ if(check()) { for(int i=1;i<=n;i++) printf("%d ",b[i]); printf("\n"); return ; } } for(int i=1;i<=n;i++){ if(vis[i]) continue; b[cur]=i; vis[i]=1; dfs(cur+1); vis[i]=0; b[cur]=0; } return ; } int main(void){ scanf("%d%d",&n,&x); for(int i=1;i<=n;i++) scanf("%d",&a[i]); dfs(1); return 0; }


Judgement Protocol: