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>
#define F first
#define S second
#define pb push_back
#define ppb pop_back
#define ep insert
#define endl '\n'
#define elif else if
#define pow pwr
#define sqrt sqrtt
#define int long long
#define ll long long
typedef unsigned long long ull;
using namespace std;
const int N=20+5;
int n,t,s,f[2][N];
vector<int> a[N];
int32_t main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
cin>>n>>s>>t;
for (int i=0;i<n;i++){
a[i].resize(s);
for (int j=0;j<s;j++) cin>>a[i][j];
}
for (int mask=0;mask<(1<<n);mask++){
for (int i=0;i<n;i++) if (mask&(1<<i)) swap(a[i][0],a[i][1]);
memset(f,0,sizeof(f));
for (int i=0;i<n;i++) f[0][a[i][0]]++,f[1][a[i][1]]++;
bool ok=true;
for (int i=1;i<=t;i++) ok&=(abs(f[0][i]-f[1][i])<=1);
if (ok){
for (int i=0;i<n;i++){
for (int j=0;j<2;j++) cout<<a[i][j]<<' ';
cout<<endl;
}
return 0;
}
for (int i=0;i<n;i++) if (mask&(1<<i)) swap(a[i][0],a[i][1]);
}
return 0;
}
# | 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... |
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |