Submission #208723

#TimeUsernameProblemLanguageResultExecution timeMemory
208723FischerPlaninarenje (COCI18_planinarenje)C++14
160 / 160
340 ms764 KiB
#include <bits/stdc++.h> using namespace std; struct BipartiteMatcher { vector<vector<int>> g; vector<int> L, R; vector<bool> vis; BipartiteMatcher(int n, int m): g(n), L(n, -1), R(m, -1), vis(n) {} void addEdge(int a, int b) { g[a].push_back(b); } bool match(int x) { if (vis[x]) return 0; vis[x] = 1; for (int v : g[x]) if (R[v] == -1) return R[L[x] = v] = x, 1; for (int v : g[x]) if (match(R[v])) return R[L[x] = v] = x, 1; return 0; } vector<int> solve() { int cnt = 1; while (cnt--) { fill(vis.begin(), vis.end(), 0); for (int i = 0; i < L.size(); ++i) cnt |= L[i] == -1 and match(i); } vector<int> res(L.size()); for (int i = 0; i < L.size(); ++i) { if (L[i] == -1) res[i] = 1; else { fill(vis.begin(), vis.end(), 0); vis[i] = 1; int v= L[i]; R[v] = -1; L[i] = -1; cnt = 0; for (int i = 0; i < L.size(); ++i) { cnt |= L[i] == -1 and match(i); } if (cnt) { res[i] = 1; } else { res[i] = 0; R[L[i] = v] = i; } } } return res; } }; int main() { int n, m; cin >> n >> m; BipartiteMatcher BM(n, n); for (int i = 1; i <= m; ++i) { int a, b; cin >> a >> b; BM.addEdge(a - 1, b - 1); } vector<int> res = BM.solve(); for (int v : res) { cout << (v ? "Mirko" : "Slavko") << endl; } return 0; }

Compilation message (stderr)

planinarenje.cpp: In member function 'std::vector<int> BipartiteMatcher::solve()':
planinarenje.cpp:32:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for (int i = 0; i < L.size(); ++i)
                    ~~^~~~~~~~~~
planinarenje.cpp:36:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < L.size(); ++i) {
                   ~~^~~~~~~~~~
planinarenje.cpp:44:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < L.size(); ++i) {
                     ~~^~~~~~~~~~
#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...