제출 #227933

#제출 시각아이디문제언어결과실행 시간메모리
227933NONAMETeoretičar (COCI18_teoreticar)C++17
26 / 130
838 ms262148 KiB
#include <bits/stdc++.h> #define sz(x) int(x.size()) #define in(x) freopen(x, "r", stdin) #define out(x) freopen(x, "w", stdout) #define N 100500 #define oo ll(1e16) #define ft first #define sd second #define pb push_back #define ppb pop_back #define el '\n' #define elf endl #define base ll(1e9 + 7) using namespace std; typedef long long ll; typedef long double ld; ll a, b, m, kl[N], v[N], u[N], mx; set <ll> se[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // in("input.txt"); cin >> a >> b >> m; for (ll i = 0; i < m; i++) cin >> v[i] >> u[i], v[i]--, u[i]--, kl[v[i]]++, kl[a + u[i]]++; for (ll i = 0; i < a + b; i++) mx = max(mx, kl[i]); ll lg = 0; while ((1ll << lg) < mx) lg++; mx = (1ll << lg); for (ll i = 0; i < a + b; i++) for (ll j = 1; j <= mx; j++) se[i].insert(j); cout << mx << el; for (ll i = 0; i < m; i++) { for (set <ll> :: iterator it = se[v[i]].begin(); it != se[v[i]].end(); it++) if (se[a + u[i]].find(*it) != se[a + u[i]].end()) { cout << (*it) << el; se[a + u[i]].erase(se[a + u[i]].find(*it)); se[v[i]].erase(it); break; } } }
#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...