Submission #631206

#TimeUsernameProblemLanguageResultExecution timeMemory
631206Vladth11Planinarenje (COCI18_planinarenje)C++14
160 / 160
499 ms1140 KiB
#include <bits/stdc++.h> #define debug(x) cerr << #x << " " << x << "\n" #define debugs(x) cerr << #x << " " << x << " " using namespace std; typedef long long ll; typedef pair <ll, ll> pii; typedef pair <long double, pii> muchie; const ll NMAX = 10001; const ll VMAX = 101; const ll INF = (1LL << 60); const ll MOD = 1000000007; const ll BLOCK = 447; const ll base = 117; const ll nr_of_bits = 18; const ll inv2 = 500000004; int match[NMAX]; vector <int> v[NMAX]; int viz[NMAX]; int restricted; bool DFS(int node) { viz[node] = 1; if(node == restricted) return 0; for(auto x : v[node]) { if(!match[x]) { match[node] = x; match[x] = node; return 1; }else if(!viz[match[x]] && DFS(match[x])){ match[node] = x; match[x] = node; return 1; } } return 0; } int main() { //ifstream cin(".in"); //ofstream cout(".out"); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, i, m; cin >> n >> m; for(i = 1; i <= m; i++) { int a, b; cin >> a >> b; b += n; v[a].push_back(b); v[b].push_back(a); } int cuplajI = 0; for(int j = 1; j <= n; j++) { viz[j] = 0; } int ok = 1; while(ok) { ok = 0; for(i = 1; i <= n; i++) viz[i] = 0; for(i = 1; i <= n; i++) { if(!viz[i] && !match[i]) { ok |= DFS(i); } } } for(i = 1; i <= n; i++) { cuplajI += (match[i] > 0); } for(i = 1; i <= n; i++) { match[match[i]] = 0; match[i] = 0; restricted = i; for(int j = 1; j <= n; j++) { viz[j] = 0; } int ok = 1; while(ok) { ok = 0; for(int peak = 1; peak <= n; peak++) { viz[peak] = 0; } for(int peak = 1; peak <= n; peak++) { if(!viz[peak] && !match[peak]) { ok |= DFS(peak); } } } int cuplajA = 0; for(int peak = 1; peak <= n; peak++) { cuplajA += (match[peak] > 0); } if(cuplajA == cuplajI){ cout << "Mirko\n"; }else{ cout << "Slavko\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...