This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e15;
int TC;
int K,cnt[15];
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//freopen("in","r",stdin);
//freopen("out","w",stdout);
cin >> TC;
while(TC--)
{
cin >> K;
int sum = 0;
for(int i=1;i<=9;i++) cin >> cnt[i] , sum += cnt[i];
if(abs(cnt[1]-cnt[2]) <= 1)
{
if(cnt[1] < cnt[2])
{
while(cnt[1]--)
cout << 2 << 1;
if(cnt[2])
cout << 2;
cout << endl;
}
else
{
while(cnt[2]--)
cout << 1 << 2;
if(cnt[1])
cout << 1;
cout << endl;
}
}
else if(cnt[2] < cnt[1])
{
while(cnt[2]--)
cout << 2 << 1;
while(cnt[1]--)
cout << 1;
cout << endl;
}
else
{
while(cnt[1]--) cout << 1;
while(cnt[2]--) cout << 2;
cout << endl;
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |