Submission #228193

#TimeUsernameProblemLanguageResultExecution timeMemory
228193VimmerTeoretičar (COCI18_teoreticar)C++14
52 / 130
12088 ms20716 KiB
#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 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...