-
Notifications
You must be signed in to change notification settings - Fork 0
/
104C.cpp
94 lines (86 loc) · 1.39 KB
/
104C.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
#define nuke ll t; cin>>t; while(t--)
#define nuke_google ll t; cin>>t; for(ll i_1=1;i_1<=t;i_1++)
#define imback ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
signed main()
{
imback;
nuke
{
ll n;
cin>>n;
ll atmax = INT_MAX;
vector<ll>result;
for(ll p=0;p<((n*3)+1);p++)
{
ll cnt = 0;
vector<ll>arr1(n,0);
vector<ll>res;
bool ok = true;
for(ll i=0;i<n-1;i++)
{
for(ll k=i+1;k<n;k++)
{
if(arr1[i] + 3 <= p)
{
arr1[i]+=3;
res.push_back(1);
continue;
}
else if(arr1[i]< p)
{
arr1[i]+=1;
res.push_back(0);
arr1[k]+=1;
cnt++;
continue;
}
if(arr1[k] + 3 <= p)
{
arr1[k]+=3;
res.push_back(-1);
continue;
}
else if(arr1[i] < p)
{
arr1[i]+=1;
res.push_back(0);
arr1[k]+=1;
cnt++;
continue;
}
else
{
ok = false;
break;
}
}
}
if(!ok)
{
continue;
}
else
{
ll mn = *min_element(arr1.begin(),arr1.end());
ll mx = *max_element(arr1.begin(),arr1.end());
if(mn == p && mx == p)
{
if(atmax > cnt)
{
atmax = cnt;
result = res;
}
}
}
}
for(ll i=0;i<result.size();i++)
{
cout<<result[i]<<" ";
}
cout<<endl;
}
}