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 pii pair<int,int>
#define ft first
#define sd second
#define MP make_pair
#define sz(x) ((int)x.size())
using namespace std;
typedef long long ll;
const int N = 5010;
int col[N], l, r, mrk[2][N][N], m, ans = 0;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> l >> r >> m;
for (int i = 0; i < m; i++){
int x, y;
cin >> x >> y;
x--; y--;
for (int c = 0; ; c++)
if (!mrk[0][x][c] && !mrk[1][y][c]){
col[i] = c;
ans = max(ans, c);
mrk[0][x][c] = mrk[1][y][c] = 1;
break;
}
}
cout << ans + 1 << '\n';
for (int i = 0; i < m; i++)
cout << col[i] + 1 << '\n';
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... |