Submission #112866

#TimeUsernameProblemLanguageResultExecution timeMemory
112866mohammadrobotPlaninarenje (COCI18_planinarenje)C++17
160 / 160
4 ms768 KiB
/* بسم الله الرحمن الرحیم (; طلا یک جهانی */ #include <bits/stdc++.h> using namespace std; const int MAX_N = 5000 + 5; int n, m, mch[MAX_N]; bool mark[MAX_N], mch_mark[MAX_N]; vector<int> adj[MAX_N]; void read_input() { cin >> n >> m; for (int i = 0; i < m; i++) { int u, v; cin >> u >> v; u--, v--; adj[u].push_back(v); } } bool dfs(int v) { mark[v] = true; for (int u: adj[v]) if (!~mch[u] || !mark[mch[u]] && dfs(mch[u])) { mch[u] = v; mch_mark[v] = true; return true; } return false; } void solve() { memset(mch, -1, sizeof mch); for (bool check = true; check; memset(mark, 0, sizeof mark)) { check = false; for (int i = 0; i < n; i++) if (!mark[i] && !mch_mark[i]) check |= dfs(i); } for (int i = 0; i < n; i++) if (!mch_mark[i]) dfs(i); } void print_output() { for (int i = 0; i < n; i++) if (mark[i]) cout << "Mirko\n"; else cout << "Slavko\n"; } int main() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); read_input(); solve(); print_output(); }

Compilation message (stderr)

planinarenje.cpp: In function 'bool dfs(int)':
planinarenje.cpp:28:33: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   if (!~mch[u] || !mark[mch[u]] && dfs(mch[u])) {
                   ~~~~~~~~~~~~~~^~~~~~~~~~~~~~
#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...