제출 #257013

#제출 시각아이디문제언어결과실행 시간메모리
257013mohamedsobhi777Teoretičar (COCI18_teoreticar)C++14
26 / 130
12083 ms262148 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e2 + 7; int l, r, m; vector<pair<int, int>> e; map<pair<int, int>, int> cols; bool check(int x) { map<int, int> chs[x + 1]; for (auto u : e) { bool ok = 0; for (int j = 0; j < x; j++) { if (!(chs[j][u.first] | chs[j][u.second])) { ok = 1; cols[u] = j + 1; chs[j][u.first] = chs[j][u.second] = 1; break; } } if (!ok) return 0; } return 1; } int main() { ios_base::sync_with_stdio(0); cin.tie(); //freopen("in.in", "r", stdin); cin >> l >> r >> m; for (int i = 0; i < m; i++) { int u, v; cin >> u >> v; v += l; e.push_back({u, v}); } int lo = 1, hi = m; int ans = 0; for (; lo <= hi;) { int mid = (lo + hi) >> 1; if (check(mid)) { ans = mid; hi = mid - 1; } else { lo = mid + 1; } } cout << ans << '\n'; for (auto u : e) { cout << cols[u] << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...