#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=5e5+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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
19800 KB |
Correct |
2 |
Incorrect |
4 ms |
19804 KB |
Unexpected end of file - int32 expected |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
19800 KB |
Correct |
2 |
Correct |
177 ms |
19804 KB |
Correct |
3 |
Correct |
860 ms |
20000 KB |
Correct |
4 |
Correct |
230 ms |
19804 KB |
Correct |
5 |
Correct |
3 ms |
19800 KB |
Correct |
6 |
Execution timed out |
2075 ms |
19804 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
17 ms |
23128 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
17 ms |
23128 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
19800 KB |
Correct |
2 |
Correct |
177 ms |
19804 KB |
Correct |
3 |
Correct |
860 ms |
20000 KB |
Correct |
4 |
Correct |
230 ms |
19804 KB |
Correct |
5 |
Correct |
3 ms |
19800 KB |
Correct |
6 |
Execution timed out |
2075 ms |
19804 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
19800 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
19800 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
19800 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
17 ms |
23128 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
17 ms |
23128 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
19800 KB |
Correct |
2 |
Incorrect |
4 ms |
19804 KB |
Unexpected end of file - int32 expected |
3 |
Halted |
0 ms |
0 KB |
- |