传送门
代码:
#include <bits/stdc++.h>
#define debug(x) cout<<#x<<":"<<x<<endl;
#define f(i,a,n) for(int i=a;i<n;++i)
#define ff(i,a,n) for(int i=a;i<=n;++i)
#define IN freopen("E:\\信竞\\信竞文件夹\\in_c.TXT","r",stdin);
const int INF=0x3f3f3f3f;
using namespace std;
typedef long long ll;
const int N=105;
vector<int> v[N];
int n,sum;
int a[N];
set<int> st;
int main(){
cin>>n;
ff(i,1,n){
cin>>a[i];
sum+=a[i];
}
sum*=10;
int pos=0;
int flag=-1,w=-1;
ff(i,1,sum+1){
pos++;
if(pos==n+1)pos=1;
while(pos<=n && v[pos].size() == a[pos] * 10){
pos++;
}
if(pos==n+1)pos=1;
if(st.size()!=n-1){
v[pos].push_back(i);
if(v[pos].size() == a[pos] * 10) st.insert(pos);
}
else {
w=i;
flag=pos;
break;
}
}
if(~flag){
int k=a[flag]*10-v[flag].size();
if(v[flag].size() && v[flag][v[flag].size()-1]==w-1)w++;
f(i,0,k){
v[flag].push_back(w);
w+=2;
}
}
ff(i,1,n){
cout<<"#"<<i<<endl;
for(int j=0; j < v[i].size(); j++){
if(j%10!=9)cout << v[i][j] << " ";
else cout << v[i][j] << endl;
}
}
return 0;
}
希望大佬能帮忙解决QAQ
|