이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")
#define F first
#define S second
#define sz(x) int(x.size())
#define pb push_back
#define N 100005
#define M ll(1e9 + 7)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef short int si;
int ans[N * 5];
int mk[N][2];
int main()
{
//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n, m, k;
cin >> n >> m >> k;
int clr = 1;
vector <pair <int, pair <int, int> > > g(k);
for (int i = 0; i < k; i++)
{
cin >> g[i].S.F >> g[i].S.S;
g[i].F = i;
}
vector <pair <int, pair <int, int> > > nxt;
while (sz(g) > 0)
{
nxt.clear();
for (auto it : g)
{
int a = it.S.F, b = it.S.S;
if (mk[a][0] != clr && mk[b][1] != clr)
{
mk[a][0] = mk[b][1] = clr;
ans[it.F] = clr;
}
else nxt.pb(it);
}
g = nxt;
clr++;
}
cout << clr - 1 << endl;
for (int i = 0; i < k; i++) cout << ans[i] << '\n';
}
# | 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... |