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;
#define arr array
#define pii pair<int, int>
#define fir first
#define sec second
const int R = 1e5 + 5, C = 2 + 5, K = 1e5 + 5, INF = 1e9;
int r, c, k;
arr<arr<int, C>, R> vl;
arr<int, K> blnc;
int main() {
// freopen("bl.in", "r", stdin);
cin >> r >> c >> k; assert(c == 2);
for (int i = 1; i <= r; i++)
for (int j = 1; j <= c; j++)
cin >> vl[i][j];
for (int msk = 0; msk < (1 << r); msk++) {
fill(blnc.begin() + 1, blnc.begin() + k + 1, 0);
for (int i = 1; i <= r; i++) {
if (msk & (1 << (i - 1))) blnc[vl[i][1]]++, blnc[vl[i][2]]--;
else blnc[vl[i][1]]--, blnc[vl[i][2]]++;
}
bool hlt = false;
for (int i = 1; i <= k; i++)
if (abs(blnc[i]) >= 2) hlt = true;
if (hlt) continue;
for (int i = 1; i <= r; i++) {
if (msk & (1 << (i - 1))) cout << vl[i][1] << " " << vl[i][2] << endl;
else cout << vl[i][2] << " " << vl[i][1] << endl;
}
break;
}
}
# | 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... |