題意:n我的要打m輪比賽ios
每一輪每一個人都要有一個對手。並且每一個對手只能打一次。假設a與b打了,c與d打了,ui
那麼後面的任意一輪若是a與c打了,那麼b就必須和d打spa
問是否存在方案,輸出字典序最小的一組,無解輸出Impossiblecode
sigma n,m<=5e3blog
思路:……這場輸的心服口服string
1 #include<cstdio> 2 #include<cstring> 3 #include<string> 4 #include<cmath> 5 #include<iostream> 6 #include<algorithm> 7 #include<map> 8 #include<set> 9 #include<queue> 10 #include<vector> 11 using namespace std; 12 typedef long long ll; 13 typedef unsigned int uint; 14 typedef unsigned long long ull; 15 typedef pair<int,int> PII; 16 typedef vector<int> VI; 17 #define fi first 18 #define se second 19 #define MP make_pair 20 #define N 210000 21 #define M 51 22 #define MOD 1000000007 23 #define eps 1e-8 24 #define pi acos(-1) 25 #define oo 1010000000 26 27 int lowbit(int x) 28 { 29 return x&(-x); 30 } 31 32 33 int main() 34 { 35 int cas; 36 scanf("%d",&cas); 37 for(int v=1;v<=cas;v++) 38 { 39 int n,m; 40 scanf("%d%d",&n,&m); 41 if(m>=lowbit(n)) printf("Impossible\n"); 42 else 43 { 44 for(int i=1;i<=m;i++) 45 { 46 for(int j=0;j<n-1;j++) printf("%d ",(i^j)+1); 47 printf("%d\n",(i^(n-1))+1); 48 } 49 } 50 } 51 return 0; 52 } 53